date
Used to output the date of the logging
event in the local time zone. To
output the date in universal time use
the %utcdate pattern. The date
conversion specifier may be followed
by a date format specifier enclosed
between braces. For example,
%date{HH:mm:ss,fff} or %date{dd MMM
yyyy HH:mm:ss,fff}. If no date format
specifier is given then ISO8601 format
is assumed (Iso8601DateFormatter).
The date format specifier admits the
same syntax as the time pattern string
of the ToString.
For better results it is recommended
to use the log4net date formatters.
These can be specified using one of
the strings "ABSOLUTE", "DATE" and
"ISO8601" for specifying
AbsoluteTimeDateFormatter,
DateTimeDateFormatter and respectively
Iso8601DateFormatter. For example,
%date{ISO8601} or %date{ABSOLUTE}.
These dedicated date formatters
perform significantly better than
ToString.
utcdate
Used to output the date of the logging
event in universal time. The date
conversion specifier may be followed
by a date format specifier enclosed
between braces. For example,
%utcdate{HH:mm:ss,fff} or %utcdate{dd
MMM yyyy HH:mm:ss,fff}. If no date
format specifier is given then ISO8601
format is assumed
(Iso8601DateFormatter).
The date format specifier admits the
same syntax as the time pattern string
of the ToString.
For better results it is recommended
to use the log4net date formatters.
These can be specified using one of
the strings "ABSOLUTE", "DATE" and
"ISO8601" for specifying
AbsoluteTimeDateFormatter,
DateTimeDateFormatter and respectively
Iso8601DateFormatter. For example,
%utcdate{ISO8601} or
%utcdate{ABSOLUTE}.
These dedicated date formatters
perform significantly better than
ToString.
Best Answer
The other answers escape the "g" in "log" since "g" is a special character in datePattern. This isn't wrong, but I prefer to wrap the entire set of non-date characters in single quotes, like so:
This gives the same results, but is easier for me to manage. This way, I don't have to recall which specific characters are special for datePattern (the list is long and varied). If I forget one character then I don't run the risk of borking my file names; they're all nicely escaped en masse.