logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralph Goers (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-470) Resolution of ${hostName} in log4j2.xml file only works after first reference
Date Sat, 04 Jan 2014 22:05:51 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Ralph Goers updated LOG4J2-470:
-------------------------------

    Description: 
I am using $\{hostName} to include the hostname in the log file.  When I use it it resolves
to "$\{hostName}" the first time it is referred to in the log and then the proper hostname
after that.

Example configuration (comment out the "Properties" section to duplicate):
{code}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="60"	name="SMSLog4JConfiguration"> <!-- add this to
spit out debug about configuration: 'status="debug"'  -->

	<!-- This seems to be a bug, but the $hostName seems to need to be referenced
	     once before it can be used.  Maybe it gets correct in a future log4j2 release -->

	<Properties>
		<Property name="theHostName">${hostName}</Property>
	</Properties>


	<Appenders>
		<RollingFile name="RollingFileAppender" fileName="/applicationlogs/CTMSApplicationService-${hostName}.log"
			filePattern="/applicationlogs/${hostName}-%d{MM-dd-yyyy}-%i.log">
			<Policies>
				<OnStartupTriggeringPolicy />
				<TimeBasedTriggeringPolicy interval="24" modulate="true" />
			</Policies>
			<PatternLayout pattern="[%d{ISO8601}] [%t] %-5level %logger{6} - %msg%n" />
		</RollingFile>
	</Appenders>
	<Loggers>
		<!-- default for "includeLocation" is false, but I want to be clear -->
		<Root level="debug" includeLocation="false">
			<AppenderRef ref="RollingFileAppender" />
		</Root>
	</Loggers>
</Configuration>
{code}

  was:
I am using ${hostName} to include the hostname in the log file.  When I use it it resolves
to "${hostName}" the first time it is referred to in the log and then the proper hostname
after that.

Example configuration (comment out the "Properties" section to duplicate):
<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="60"	name="SMSLog4JConfiguration"> <!-- add this to
spit out debug about configuration: 'status="debug"'  -->

	<!-- This seems to be a bug, but the $hostName seems to need to be referenced
	     once before it can be used.  Maybe it gets correct in a future log4j2 release -->

	<Properties>
		<Property name="theHostName">${hostName}</Property>
	</Properties>


	<Appenders>
		<RollingFile name="RollingFileAppender" fileName="/applicationlogs/CTMSApplicationService-${hostName}.log"
			filePattern="/applicationlogs/${hostName}-%d{MM-dd-yyyy}-%i.log">
			<Policies>
				<OnStartupTriggeringPolicy />
				<TimeBasedTriggeringPolicy interval="24" modulate="true" />
			</Policies>
			<PatternLayout pattern="[%d{ISO8601}] [%t] %-5level %logger{6} - %msg%n" />
		</RollingFile>
	</Appenders>
	<Loggers>
		<!-- default for "includeLocation" is false, but I want to be clear -->
		<Root level="debug" includeLocation="false">
			<AppenderRef ref="RollingFileAppender" />
		</Root>
	</Loggers>
</Configuration>



> Resolution of ${hostName} in log4j2.xml file only works after first reference
> -----------------------------------------------------------------------------
>
>                 Key: LOG4J2-470
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-470
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configurators
>    Affects Versions: 2.0-beta9
>         Environment: Windows 7, JDK 1.7, Eclipse 4.2
>            Reporter: Russell J. Nile
>            Priority: Minor
>
> I am using $\{hostName} to include the hostname in the log file.  When I use it it resolves
to "$\{hostName}" the first time it is referred to in the log and then the proper hostname
after that.
> Example configuration (comment out the "Properties" section to duplicate):
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration monitorInterval="60"	name="SMSLog4JConfiguration"> <!-- add this
to spit out debug about configuration: 'status="debug"'  -->
> 	<!-- This seems to be a bug, but the $hostName seems to need to be referenced
> 	     once before it can be used.  Maybe it gets correct in a future log4j2 release -->

> 	<Properties>
> 		<Property name="theHostName">${hostName}</Property>
> 	</Properties>
> 	<Appenders>
> 		<RollingFile name="RollingFileAppender" fileName="/applicationlogs/CTMSApplicationService-${hostName}.log"
> 			filePattern="/applicationlogs/${hostName}-%d{MM-dd-yyyy}-%i.log">
> 			<Policies>
> 				<OnStartupTriggeringPolicy />
> 				<TimeBasedTriggeringPolicy interval="24" modulate="true" />
> 			</Policies>
> 			<PatternLayout pattern="[%d{ISO8601}] [%t] %-5level %logger{6} - %msg%n" />
> 		</RollingFile>
> 	</Appenders>
> 	<Loggers>
> 		<!-- default for "includeLocation" is false, but I want to be clear -->
> 		<Root level="debug" includeLocation="false">
> 			<AppenderRef ref="RollingFileAppender" />
> 		</Root>
> 	</Loggers>
> </Configuration>
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message