MojoPortal And Log4net

3,168 views
3,066 views

Published on

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

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,168
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

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
  • MojoPortal And Log4net

    1. 1. MojoPortal and log4net<br />Steve Land<br />StrongEye Solutions LLC<br />VerifiedAD.com<br />
    2. 2.
    3. 3. Viewing logs in MojoPortal<br />
    4. 4. currentlog.config<br />
    5. 5. Log4net.config<br />
    6. 6. Logging vs. Debugging<br />
    7. 7.  Everyone likes to write a logging framework<br />“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.” <br />Dr. Heinz M. Kabutz, The Java Specialists Newsletter<br />Stan Wagon, Prof. of Mathematics and Computer Science, Macalester College, St. Paul, Minnesotahttp://decision-making.moshe-online.com/wheel.html<br />
    8. 8. Basic concepts<br />Tracing<br />Dump every action and step, timestamped<br />Logging<br />Log business process steps<br />Error Reporting / Debugging<br />Log exceptions, unexpected cases<br />
    9. 9. Log4Net features<br />Log to multiple targets per log via Appenders<br />Configurable message format<br />Different logging levels off, fatal, error, warn, info, debug, and all<br />Each logger has its own logging level<br />Runtime control on which statements are printed<br />Filters allow you to add conditions to Appenders to restrict what data gets written<br />
    10. 10. http://www.codeproject.com/KB/cs/log4net_XmlConfigurator.aspx#objects<br />
    11. 11. Good things to log<br />Startup / shutdown of application<br />Object creation<br />Scarce resource allocation<br />Failures (recoverable / unrecoverable)<br />How long performance-critical operations took<br />
    12. 12. Levels and tips<br />ALL<br />DEBUG<br />INFO<br />WARN<br />ERROR<br />FATAL<br />OFF<br />Tips generally follow http://commons.apache.org/logging/guide.html<br />Selected level <br />and above <br />are reported<br />
    13. 13. DEBUG level<br />Detailed information on the flow through the system. <br />Expected exceptions that users of your code should handle.<br />Logging details that you would not expect to see in production.<br />
    14. 14. INFO level<br />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.<br />Components that rely on network boundaries should use INFO, don’t assume exceptions will make it to other components.<br />Logging details that may be useful in production during troubleshooting.<br />
    15. 15. WARN level<br />Use of deprecated APIs, poor usage of APIs, “almost” errors, other unexpected and undesirable runtime situations that are not necessarily “wrong”<br />
    16. 16. ERROR level<br />Other runtime errors or unexpected conditions that may not cause premature termination.<br />
    17. 17. FATAL level<br />Severe errors that cause premature termination.<br />
    18. 18. Things to be careful about<br />Ensure logs don’t contain sensitive data<br />Consider how attackers could use logs to defeat your software. Don’t reveal more information than necessary.<br />Recursive code with logging<br />Definitions of levels<br />Not too much logging<br />When performance is important, don’t create logging related objects if logging is turned off<br />
    19. 19.
    20. 20. Appenders<br />In the box<br />AdoNetAppender<br />AspNetTraceAppender<br />ConsoleAppender<br />DebugAppender<br />EventLogAppender<br />FileAppender<br />MemoryAppender<br />RemotingAppender<br />RollingFileAppender (  MojoPortal default)<br />SmtpAppender<br />SmtpPickupDirAppender<br />… and more<br />Or, make your own<br />Start from scratch (probably don’t need to do this)<br />Start from existing Appenderoverride methods that don’t do exactly what you want<br />
    21. 21. Locking Models (for file appenders)<br />MinimalLock: Opens the file once for each cycle. Slower but allows other processes to move/delete the log while logging<br />ExclusiveLock: Opens the file once for writing and holds it open until CloseFile is called. Higher performance, but not appropriate for Web applications.<br />
    22. 22. Layouts<br />The recognized conversion pattern names are:<br />log4net.Layout.PatternLayoutsee http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html<br />
    23. 23. Demo<br />
    24. 24. Thanks!<br />Steve Land<br />StrongEye Solutions<br />VerifiedAD.com<br />

    ×