While working on the
logging configuration for sending messages via email last week, I realised that all the documentation I could find for the
So with a bit of research, I've dug out the important values that can be used in case anyone else needs to configure log messages in older versions of Sitecore:
-
Thread identifer:
%tThe operating system identifier for the thread raising the log message -
Date:
%dThe date at which the log message was created. Can be modified by appending a format parameter in curly braces. The code describes the set as being IS08601, ABSOLUTE and DATE, however the old log4j documentation implies any valid date-type format string could be used here. -
Message priority level:
%pThe severity of the log message, when it was recorded. -
Log identifer:
%CReturns the fully qualified class name that raised the log message. -
Line number:
%LThe source code line number for the method. This does not seem to display a value for messages logged by Sitecore itself. -
Process identity:
%WThe windows username of the process identity running the code which logged the message. -
AppDomain identifier:
%aThe identifier set when the AppDomain was created by IIS. -
Reporting class:
%cSimilarly to%C, seems to return the fully qualified name of the class raising the log message. -
Reporting method:
%land%MThe name of the logging method that was called to record the message. %l returns the fully qualified method name, and %M just the name of the method called. -
Log message:
%mThe full text of the log message that was recorded. - **Time taken to record the log message:
%rRecords the time difference (in milliseconds) between the time the logging event begins and the time the log event record is complete. -
New line:
%nWrites a line ending. -
Mapped Diagnistic Context:
%X/ Nested Diagostic Context:%xThese two patterns let you output custom data that has been recorded during the logging session. You specify what item from the internal log data collection you want by supplying its key in curly braces after the format specifier. e.g. "%X" These might be useful if you were writing your own custom log data, but as far as I can see from a bit of reflection-based investigation there's no data recorded here by default. There are some docs available for log4j which cover how this works.
If you need to output a
%
character, use
%%.
Logging patterns can also include a column width format, by placing a number between the
%
and the pattern character. For example
%4t
will ensure the field occupies at least four characters and align it to the right of the space. Use a negative number to align to the left:
%-5p.
Hopefully that'll be of help to someone other than me...
↑ Back to top