[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4j-dev
Subject:    [jira] [Commented] (LOG4J2-746) Custom Appender
From:       "Radek Miazio (JIRA)" <jira () apache ! org>
Date:       2014-07-29 10:29:38
Message-ID: JIRA.12729701.1406286386470.64445.1406629778781 () arcas
[Download RAW message or body]


    [ https://issues.apache.org/jira/browse/LOG4J2-746?page=com.atlassian.jira.plugin. \
system.issuetabpanels:comment-tabpanel&focusedCommentId=14077588#comment-14077588 ] 

Radek Miazio commented on LOG4J2-746:
-------------------------------------

Looks like fixed. 
Appender has been discovered and used.
However, turned out appender that I was hoping to use \
(https://github.com/getsentry/raven-java/tree/master/raven-log4j2) does not support \
latest log4j2, so I wasnt able to test the solution it completely.

> Custom Appender
> ---------------
> 
> Key: LOG4J2-746
> URL: https://issues.apache.org/jira/browse/LOG4J2-746
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 2.0
> Environment: Windows 7 (x64), Java 7, Tomcat 7
> Reporter: Radek Miazio
> Labels: appender, configuration
> Fix For: 2.0.1
> 
> 
> I want to configure \
> [Sentry|https://github.com/getsentry/raven-java/tree/master/raven-log4j2] to to be \
> working with log4j2. To do that I need to add sentry appender to log4j2.xml file.
> Actually it does not differ from configuring custom appender.
> Manual page suggests that I need to add package with the appender to "packages" \
> attribute of Configuration element: \
> http://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax \
> My log4j2.xml file looks like this: {code}
> <Configuration status="trace" packages="net.kencochrane.raven.log4j2">
> 	<Appenders>
> 		<Console name="Console" target="SYSTEM_OUT">
> 			<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
> 		</Console>
> 		<Raven name="Sentry">
> 			<dsn>
> 				https://publicKey:secretKey@host:port/1?options
> 			</dsn>
> 		</Raven>		
> 	</Appenders>
> 	<Loggers>	
> 		<Root level="error">
> 			<AppenderRef ref="Console" />
> 			<AppenderRef ref="Sentry" />
> 		</Root>
> 	</Loggers>
> </Configuration> 
> {code}
> Package 'net.kencochrane.raven.log4j2' contains a class that extends \
> 'org.apache.logging.log4j.core.appender.AbstractAppender'. However, looks like it \
> is completely ignored. After some digging, I found out, that PluginManager uses \
> already defined list of existing plugins, which is available within binary file \
> (/log4j-core-2.0.jar!/META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat) \
> and "packages" attribute actually doesnt do anything, becuase the only thing that \
> XmlConfiguration does with its value is: {code}
> PluginManager.addPackage(p);
> {code}
> but the method is deprecated and empty:
> {code}
> /**
> * Adds a package name to be scanned for plugins. Must be invoked prior to plugins \
>                 being collected.
> * @param p The package name.
> */
> @Deprecated // no more need for this method due to PluginProcessor
> public static void addPackage(final String p) {
> }
> {code}
> As you can see, Javadoc points to PluginProcessor, which actually should create \
> proper binary file based on Plugin annotation. However putting a breakpoint in \
> 'process' method showed that it is not invoked during the log4j initialization. \
> Similar issue was already reported and resolved \
> https://issues.apache.org/jira/browse/LOG4J2-95 but looks like problem came up \
> again, and suggestes workaround dont work anymore. What should I do to force \
> PluginProcessor create Log4j2Plugins.dat file again?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic