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:
%t
The operating system identifier for the thread raising the log message%d
The 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.%p
The severity of the log message, when it was recorded.%C
Returns the fully qualified class name that raised the log message.%L
The source code line number for the method. This does not seem to display a value for messages logged by Sitecore itself.%W
The windows username of the process identity running the code which logged the message.%a
The identifier set when the AppDomain was created by IIS.%c
Similarly to
%C
, seems to return the fully qualified name of the class raising the log message.%l
and
%M
The 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.%m
The full text of the log message that was recorded.%r
Records the time difference (in milliseconds) between the time the logging event begins and the time the log event record is complete.%n
Writes a line ending.%X
/ Nested Diagostic Context:
%x
These 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