Error in log4j2.properties configuration

Asked

Viewed 139 times

1

My mistake:

2018-02-02 03:31:07,300 main ERROR The parameter is null: fileName
2018-02-02 03:31:07,316 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.FileAppender for element File org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element File 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:152)
    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.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
    at client.LoadWebService.<clinit>(LoadWebService.java:54)

2018-02-02 03:31:07,323 main ERROR Null object returned for File in Appenders.
2018-02-02 03:31:07,323 main ERROR Unable to locate appender "LOGFILE" for logger config "root"
2018-02-02 03:31:07,323 main ERROR Unable to locate appender "LOGFILE" for logger config "org.apache.logging.slf4j.log4j2.properties"

My log4j2.properties configuration file

# WebService

name = client.LoadWebService
property.filename = ./logs
appenders = console, file

# Direct log messages to Console
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%-5level] %d{dd MMM yyyy HH:mm:ss} [%t] %c{10} - %msg%n

# Direct log messages to a log File
appender.file.type = File
appender.file.name = LOGFILE
appender.file.File = ${filename}/WebService %d{dd-MM-yyyy-HH-mm-ss}.log
appender.file.DatePattern = '.'yyyyMMdd
appender.file.layout.type = PatternLayout
appender.file.layout.pattern = [%-5level] %d{dd MMM yyyy HH:mm:ss} [%t] %c{10} - %msg%n

loggers = file
logger.file.name = org.apache.logging.slf4j.log4j2.properties
logger.file.level = DEBUG
logger.file.appenderRefs = file
logger.file.appenderRef.file.ref = LOGFILE
logger.file.additivity = false

# Configure the loggers
rootLogger.level = DEBUG
rootLogger.appenderRefs = stdout, file
rootLogger.appenderRef.stdout.ref = STDOUT
rootLogger.appenderRef.file.ref = LOGFILE

Statement:

private static Logger logger = LoggerFactory.getLogger(LoadWebService.class);

Validation:

logger.info("WEBSERVICE CRIADO.");

The console part is apparently ok. But no file is created

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.