[ http://issues.apache.org/jira/browse/LOG4NET-26?page=all ] Nicko Cadell resolved LOG4NET-26: ---------------------------------
Assign To: Nicko Cadell Resolution: Won't Fix The PatternLayout exists to log information that is specific to a LoggingEvent. Consider the situation where a LoggingEvent is remoted from one process to another on the same machine using the RemotingAppender. If the event is now relogged into a FileAppender with some form of %processid patter specified which process ID should be used? Should it be the ID of the current process, the one that is logging the event it to the FileAppender, or should it be the ID of the process that generated the original event and remoted it? The process ID is not stored as part of the LoggingEvent. Therefore it is not available to the PatternLayout for inclusion in the output. In general the process ID is not a good identifier for a process, it is specific to a single machine and will also be reused on that machine from time to time. To identify the process uniquely the machine name must form part of the identifier, along with the process id and the start time. This identifier should also flow with the LoggingEvent if it is remoted from one process/machine to another. This is simple to achieve using the GlobalContext.Properties. Store an identifier in the global properties for each process and this will be attached to each LoggingEvent that is generated. For example, add the following code to your app's startup sequence: log4net.GlobalContext.Properties["pocid"] = Environment.MachineName + "-" + System.Diagnostics.Process.GetCurrentProcess().StartTime.ToUniversalTime().ToString("s") + "-" + System.Diagnostics.Process.GetCurrentProcess().Id; Then in your config you can retrieve the id using the '%property{procid}' logging pattern. You may have a different set of criteria for identifying your processes uniquely, if so then modify the property value as appropriate. Cheers, Nicko > Allow conversionPattern to output process IDs > --------------------------------------------- > > Key: LOG4NET-26 > URL: http://issues.apache.org/jira/browse/LOG4NET-26 > Project: Log4net > Type: New Feature > Components: Core > Versions: 1.2.9 > Environment: All environments > Reporter: Bryan Murphy > Assignee: Nicko Cadell > > Now that you allow file appenders from multiple applications to write to a > shared file using minimal locking, you should also include the ability to add > the process ID to the log messages. This would help determine later which > application generated each individual log message. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira