MojoPortal And Log4net

Uploaded on

MojoPortal is an ASP.NET content management system that is easily extensible by developers. Steve Land from recently led a MojoPortal User's group on on the topic of …

MojoPortal is an ASP.NET content management system that is easily extensible by developers. Steve Land from recently led a MojoPortal User's group on on the topic of log4net, which is the logging infrastructure used by MojoPortal.

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide
  • Sailors on early ships had no real way of knowing how fast they were traveling and how far they had gone in a specific period of time. So a system of measuring was devised, using a log of wood.The log had a weight tied to one end and a long rope attaching the other end to the stern, or back of the ship. The log floated behind the ship a certain distance, the length the rope was let out.Written accounts of speed Log Book
  • AspNetTraceAppender outputs to trace screen of browser when @Page Trace=“true” setDebugAppender outputs events to the System.Diagnostics.Debug.Write(..) methodFileAppender has either Append or Overwrite modeMemoryAppender stores all to array, accessible via GetEvents() method RemotingAppender sends asynchronously


  • 1. MojoPortal and log4net
    Steve Land
    StrongEye Solutions LLC
  • 2.
  • 3. Viewing logs in MojoPortal
  • 4. currentlog.config
  • 5. Log4net.config
  • 6. Logging vs. Debugging
  • 7.  Everyone likes to write a logging framework
    “Writing your own logging framework is the perfect coding crime. If you can convince your manager to put it on the project plan, you are guaranteed to have success. At the end of each day, you will go home feeling happy and satisfied. It will feel like you are doing something creative. You will get the intellectual stimulation without the risk of failure.”
    Dr. Heinz M. Kabutz, The Java Specialists Newsletter
    Stan Wagon, Prof. of Mathematics and Computer Science, Macalester College, St. Paul, Minnesota
  • 8. Basic concepts
    Dump every action and step, timestamped
    Log business process steps
    Error Reporting / Debugging
    Log exceptions, unexpected cases
  • 9. Log4Net features
    Log to multiple targets per log via Appenders
    Configurable message format
    Different logging levels off, fatal, error, warn, info, debug, and all
    Each logger has its own logging level
    Runtime control on which statements are printed
    Filters allow you to add conditions to Appenders to restrict what data gets written
  • 10.
  • 11. Good things to log
    Startup / shutdown of application
    Object creation
    Scarce resource allocation
    Failures (recoverable / unrecoverable)
    How long performance-critical operations took
  • 12. Levels and tips
    Tips generally follow
    Selected level
    and above
    are reported
  • 13. DEBUG level
    Detailed information on the flow through the system.
    Expected exceptions that users of your code should handle.
    Logging details that you would not expect to see in production.
  • 14. INFO level
    You generally want exception information available in production without having to turn on DEBUG log level. Log as INFO with stack trace and generally re-throw the exception.
    Components that rely on network boundaries should use INFO, don’t assume exceptions will make it to other components.
    Logging details that may be useful in production during troubleshooting.
  • 15. WARN level
    Use of deprecated APIs, poor usage of APIs, “almost” errors, other unexpected and undesirable runtime situations that are not necessarily “wrong”
  • 16. ERROR level
    Other runtime errors or unexpected conditions that may not cause premature termination.
  • 17. FATAL level
    Severe errors that cause premature termination.
  • 18. Things to be careful about
    Ensure logs don’t contain sensitive data
    Consider how attackers could use logs to defeat your software. Don’t reveal more information than necessary.
    Recursive code with logging
    Definitions of levels
    Not too much logging
    When performance is important, don’t create logging related objects if logging is turned off
  • 19.
  • 20. Appenders
    In the box
    RollingFileAppender (  MojoPortal default)
    … and more
    Or, make your own
    Start from scratch (probably don’t need to do this)
    Start from existing Appenderoverride methods that don’t do exactly what you want
  • 21. Locking Models (for file appenders)
    MinimalLock: Opens the file once for each cycle. Slower but allows other processes to move/delete the log while logging
    ExclusiveLock: Opens the file once for writing and holds it open until CloseFile is called. Higher performance, but not appropriate for Web applications.
  • 22. Layouts
    The recognized conversion pattern names are:
  • 23. Demo
  • 24. Thanks!
    Steve Land
    StrongEye Solutions