6

I know that logs have the following levels from lowest to highest:

  1. DEBUG
  2. INFO
  3. WARN
  4. ERROR
  5. FATAL

And that the <priority> of each log sets the minimum log level for messages that will be written to the log, i.e. only messages at that level or higher will be written to the log.

A while back, I worked on a project for a client in which the previous agency split each of the CM logs into three:

  • Detail.{logName}.txt     (DEBUG, INFO)
  • Warn.{logName}.txt     (WARN)
  • Error.{logName}.txt     (ERROR, FATAL)

I can't seem to find the project in my archives, and as far as I can tell, there doesn't appear to be a way to set both a "maximum priority" for logs, natively, though this would be great for debugging.

I don't want to reinvent the wheel, so does any one know if I'm missing something simple? Thanks!

1
  • 1
    you can use Sitecore Log Analyzer tool (marketplace module) and filter the logs as necessary. In my personal openion it is much easier to keep the logs in a single file.. Nov 11, 2016 at 17:29

2 Answers 2

12

In log4net you can use a filter on the level in your appender like this:

<threshold value="DEBUG"/>
<filter type="log4net.Filter.LevelRangeFilter">
  <levelMin value="DEBUG" />
  <levelMax value="INFO" />
</filter>

Not sure whether the syntax in Sitecore will be the same as I didn't test it. The threshold value specifies that all messages below the indicated level are ignored by this fileAppender - not sure that you need this on top of the filter but that is how I read it should be done.

Using this, you could create all the appenders you need based on the levels you want, and add multiple appenders to the loggers you want to split and have splitted log files.

1
  • This is exactly what I'm looking for! Thanks! Nov 11, 2016 at 16:44
1

If it is just dev machine, I use SIM Log analyzer

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.