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

ASF GitHub Bot commented on LOG4J2-2268:
----------------------------------------

GitHub user THausherr opened a pull request:

    https://github.com/apache/logging-log4j2/pull/160

    [LOG4J2-2268] Improve error msg if invalid value

    This will tell what field had an invalid value.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/THausherr/logging-log4j2 master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/logging-log4j2/pull/160.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #160
    
----
commit a281d56dd23ca9a5b233ad463f0fac3cd351367a
Author: Tilman Hausherr <tilman@...>
Date:   2018-03-13T21:23:02Z

    Improve error msg if invalid value

----


> Improve error msg if RollingFileAppender element missing
> --------------------------------------------------------
>
>                 Key: LOG4J2-2268
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2268
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Appenders
>    Affects Versions: 2.10.0
>         Environment: W7
>            Reporter: Tilman Hausherr
>            Priority: Minor
>
> I did my first migration from log4j 1 to 2; previously I used property and 
> now I wanted to use XML. This is my XML file:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- https://logging.apache.org/log4j/2.x/manual/configuration.html -->
> <Configuration>
>     <Appenders>
>         <RollingFile name="A1" fileName="XXX/XXX.log">
>             <PatternLayout pattern="%d{dd.MM.yyyy HH:mm:ss} %-5p %C{2}:%L - 
> %m%n"/>
>             <Policies>
>                 <SizeBasedTriggeringPolicy size="10 MB"/>
>             </Policies>
>             <DefaultRolloverStrategy fileIndex="nomax" />
>         </RollingFile>
>         <Console name="STDOUT" target="SYSTEM_OUT">
>             <PatternLayout pattern="%d{dd.MM.yyyy HH:mm:ss} %-5p %C{2}:%L - 
> %m%n"/>
>         </Console>
>     </Appenders>
>     <Loggers>
>         <Logger name="org.springframework" level="warn" additivity="false">
>             <AppenderRef ref="STDOUT"/>
>             <AppenderRef ref="A1"/>
>         </Logger>
>         <Logger name="org.apache.pdfbox.pdmodel.font.PDCIDFontType2" 
> level="fatal" additivity="false">
>             <AppenderRef ref="STDOUT"/>
>             <AppenderRef ref="A1"/>
>         </Logger>
>         <Root level="info">
>             <AppenderRef ref="STDOUT"/>
>             <AppenderRef ref="A1"/>
>         </Root>
>     </Loggers>
> </Configuration>
> {code}
> This brought me this output:
> {quote}
> 2018-02-23 12:28:22,351 main ERROR Could not create plugin of type class 
> org.apache.logging.log4j.core.appender.RollingFileAppender for element 
> RollingFile org.apache.logging.log4j.core.config.ConfigurationException: 
> Arguments given for element RollingFile are invalid
>       at 
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:203)
>       at 
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:121)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237)
>       at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)
>       at 
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
>       at 
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:617)
>       at 
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634)
>       at 
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
>       at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
>       at 
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:122)
>       at 
> org.apache.logging.log4j.jcl.LogAdapter.getContext(LogAdapter.java:39)
>       at 
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
>       at 
> org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40)
>       at 
> org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:55)
>       at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
>       at 
> org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:160)
>       at 
> org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:230)
>       at 
> org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:92)
>       at 
> org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:59)
>       at 
> org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:62)
>       at 
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:141)
>       at 
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85)
>       at XXXXX.Main.main(Main.java:67)
> 2018-02-23 12:28:22,359 main ERROR Null object returned for RollingFile in 
> Appenders.
> 2018-02-23 12:28:22,370 main ERROR Unable to locate appender "A1" for logger 
> config "org.apache.log4j.xml"
> 2018-02-23 12:28:22,371 main ERROR Unable to locate appender "A1" for logger 
> config "org.springframework"
> 2018-02-23 12:28:22,371 main ERROR Unable to locate appender "A1" for logger 
> config "org.apache.pdfbox.pdmodel.font.PDCIDFontType2"
> {quote}
> Excerpt of my pom.xml:
> {code:xml}
>         <dependency>
>             <groupId>commons-logging</groupId>
>             <artifactId>commons-logging</artifactId>
>             <version>1.2</version>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.logging.log4j</groupId>
>             <artifactId>log4j-core</artifactId>
>             <version>2.10.0</version>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.logging.log4j</groupId>
>             <artifactId>log4j-api</artifactId>
>             <version>2.10.0</version>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.logging.log4j</groupId>
>             <artifactId>log4j-jcl</artifactId>
>             <version>2.10.0</version>
>         </dependency>
> {code}
> After some searching, I found out that {{filePattern}} was missing.
> So my suggestion is that you output a better error message, here: mandatory 
> filePattern parameter is missing.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to