EPi Server and loging

Member since: 2005
 
How do you write log entries to the main Epi Server Log? I assume using log4net would be the way to do it?! Code examples would be much appreciated
#12664 Jun 04, 2006 16:21
  • Member since: 2001
     
    Go to http://www.episerver.com/technotes and then find the technote called "Logging in EPiServer". The technote does not have any example code for doing your own logging, but it is very easy: public class MyClass { private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public void DoSomething() { _log.Debug("Starting something risky"); try { int a = int.Parse("whops"); } catch (Exception ex) { _log.Error("Something crashed", ex); } _log.Debug("Ended something risky"); } } This code will show up like this in the log file: 2006-06-04 21:37:18,238 Starting something risky 2006-06-04 21:37:18,238 Something crashed Exception: System.FormatException Message: Input string was not in a correct format. Source: mscorlib at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Int32.Parse(String s) at EPiServerSample.MyClass.DoSomething() in C:\Inetpub\demo\MyEPiServer460\MyClass.cs:line 23 2006-06-04 21:37:18,258 Ended something risky I've also covered some of this in my blog: http://spaces.msn.com/stevecelius/blog I highly recommend everyone who is developing EPiServer solutions to check the log4net web site on http://logging.apache.org/log4net/ and learn about configuration and usage. Hunting down those nasty bugs and performance killers is a lot easier if you've instrumented your code thoroughly. /Steve
    #14707 Jun 04, 2006 21:44
  •  

    Hi Steve,

    I'm recieveing exactly the same error message you have pasted in above.

    Do you know the cause of this error.

    any feedback would be greatly appreciated.

    ta, mike

     

     

    [06/02/2009 15:24:57][Information] Finished migrating database data
    [06/02/2009 15:24:58][Information] Finalizing database schema...
    [06/02/2009 15:25:11][Information] Finished finalizing database schema
    [06/02/2009 15:25:11][Error] Migration terminated with error:
    [06/02/2009 15:25:11][Error] System.FormatException: Input string was not in a correct format.
       at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
       at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
       at EPiServer.Migration.WebConfig4.get_StartPage()
       at EPiServer.Migration.MigrationWorkflow.UpdateWebConfig(Object sender, EventArgs e)
       at System.Workflow.ComponentModel.Activity.RaiseEvent(DependencyProperty dependencyEvent, Object sender, EventArgs e)
       at EPiServer.Migration.MigrationStepActivity.ExecuteHandler(Object sender, EventArgs e)
       at System.Workflow.ComponentModel.Activity.RaiseEvent(DependencyProperty dependencyEvent, Object sender, EventArgs e)
       at System.Workflow.Activities.CodeActivity.Execute(ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
       at System.Workflow.Runtime.Scheduler.Run()

    #27705 Feb 06, 2009 17:07
  •  

    Mike,
    In your case I guess you did not write code to provoke the error yourself?

    My guess is that you are trying to use EPiServer Migration tool to convert an EPiServer CMS 4 solution to 5. And that error indicates that your web.config for the EPiServer 4 site is not valid since it can not read the setting for Start Page ID. It might be blank or conatin non numeric values...

    Make sure that you acutally can browse the EPiServer 4 site through your local IIS before starting migration!

    #27706 Feb 06, 2009 17:39
  •  

    excellent - I must have overlooked the Start Page ID value when copying the tags across.

    Smile

    #27707 Feb 06, 2009 18:05