You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Mike Blake-Knox <mi...@knology.net> on 2004/08/23 18:11:20 UTC

XmlLayoutSchemaLog4j and hostname

XmlLayoutSchemaLog4j wasn't providing a hostname in its output.  The code
would only provide a hostname if the hostname was already in the logging
event.  So far, I haven't seen the hostname in any logging event and I
noticed that the other appenders that provide a hostname in their output use
SystemInfo.HostName as the source.

I've solved the problem by making the code in the FormatXml method of
XmlLayoutSchemaLog4j.cs to start like following:

		override protected void FormatXml(XmlWriter writer,
LoggingEvent loggingEvent)
		{
			// Translate logging events for log4j

			// Insert hostname property if not already there
			if (loggingEvent.Properties["log4jmachinename"] ==
null)
			{
				loggingEvent.Properties["log4jmachinename"]
= SystemInfo.HostName;
			}

Mike Blake-Knox
email: MBlake-Knox@tsystsol.com
TSYS Office: (706) 644-3643
cellphone: (706) 570-4641