I'm trying to create a custom log file for my flow in Nifi; to achieve that I want to use the logback filters.
In my logback.conf I added a new appender called LLAB_FILE which filters the log message by its content:
<appender name="LLAB_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${org.apache.nifi.bootstrap.config.log.dir}/llab-transform.log</file>
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<expression>return message.contains("LLAB_TRANSFORM");</expression>
</evaluator>
<OnMismatch>DENY</OnMismatch>
<OnMatch>ACCEPT</OnMatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${org.apache.nifi.bootstrap.config.log.dir}/llab-transform_%d.%i.log</fileNamePattern>
<maxFileSize>100MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<immediateFlush>true</immediateFlush>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date~%level~%msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="LLAB_FILE"/>
</root>
However this configuration gives the following error when Nifi starts:
Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: org/codehaus/janino/ScriptEvaluator
at ch.qos.logback.core.boolex.JaninoEventEvaluatorBase.start(JaninoEventEvaluatorBase.java:57)
at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:161)
at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at org.apache.nifi.bootstrap.RunNiFi.<init>(RunNiFi.java:134)
at org.apache.nifi.bootstrap.RunNiFi.main(RunNiFi.java:231)
Caused by: java.lang.ClassNotFoundException: org.codehaus.janino.ScriptEvaluator
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 20 more
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/janino/ScriptEvaluator
at ch.qos.logback.core.boolex.JaninoEventEvaluatorBase.start(JaninoEventEvaluatorBase.java:57)
at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:161)
at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:309)
at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:193)
at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:179)
at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110)
at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
at org.apache.nifi.bootstrap.RunNiFi.<init>(RunNiFi.java:134)
at org.apache.nifi.bootstrap.RunNiFi.main(RunNiFi.java:231)
Caused by: java.lang.ClassNotFoundException: org.codehaus.janino.ScriptEvaluator
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
How can I fix this? I don't want to process the logs throw a nifi's flow.
Thanks,
Temp
http://logback.qos.ch/manual/filters.html#JaninoEventEvaluator
JaninoEventEvaluator requires the Janino library.
Please see the corresponding section of the setup document.
actually any evaluator requires additional library
Related
I have a question about this, i am going send the logback logs to rabbit, and i use spring-rabbit, as i need to send the data with json format, so i used LoggingEventCompositeJsonEncoder, here are my configuration
<appender name="AMQP" class="org.springframework.amqp.rabbit.logback.AmqpAppender">
<!--<layout>-->
<!--<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>-->
<!--</layout>-->
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<pattern>
<pattern>
{ "level": "%level" }
</pattern>
</pattern>
</encoder>
<host>127.0.0.1</host>
<port>5672</port>
<username>guest</username>
<password>guest</password>
<routingKeyPattern>testroute</routingKeyPattern>
<exchangeName>logs</exchangeName>
<declareExchange>true</declareExchange>
<generateId>true</generateId>
<charset>UTF-8</charset>
<durable>true</durable>
<deliveryMode>PERSISTENT</deliveryMode>
</appender>
but when i start the application, i got the error as below :
java.lang.IllegalStateException: Logback configuration error detected: ERROR in ch.qos.logback.core.joran.spi.Interpreter#16:88 - no applicable action for [encoder], current ElementPath is [[configuration][appender][encoder]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter#18:22 - no applicable action for [pattern], current ElementPath is [[configuration][appender][encoder][pattern]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter#19:26 - no applicable action for [pattern], current ElementPath is [[configuration][appender][encoder][pattern][pattern]]
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:162)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:81)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:59)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:115)
at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:303)
at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:276)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:212)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
That's correct the org.springframework.amqp.rabbit.logback.AmqpAppender is a AppenderBase extension, not an OutputStreamAppender which supports that encoder option.
However I'm pretty sure we can add support for it and instead of raw msgBody.getBytes() call already this.encoder.encode(event).
The JIRA on the matter: https://jira.spring.io/browse/AMQP-760.
I am using spring boot application for a project and getting the following error while running the project from jar using java -jar build/libs/com.user.admin.rest.services.jar. But its not a blocker and i was able to access the api's, and the logger is working fine as intended. I just want to resolve this error.
ERROR StatusLogger Unable to create class org.apache.logging.log4j.core.impl.Log4jContextFactory specified in jar:file:/Users/Samuel/UserMgmt/com.user.admin.rest.services/build/libs/com.user.admin.rest.services.jar!/META-INF/log4j-provider.properties
java.lang.ClassNotFoundException: org.apache.logging.log4j.core.impl.Log4jContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.logging.log4j.spi.Provider.loadLoggerContextFactory(Provider.java:96)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:91)
at com.user.admin.rest.services.api.UserServiceResource.<clinit>(UserServiceResource.java:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1147)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at com.user.admin.rest.services.api.Application.main(Application.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
I have added the following lines for logger in the build.gradle file.
compile 'org.apache.logging.log4j:log4j-api:2.8.2'
compile 'org.apache.logging.log4j:log4j-core:2.8.2'
And my log4j2.xml file is given below
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<Configuration status="ERROR" name="example-config">
<Properties>
<Property name="PATTERN">%-5level %d [%t] %c:%M(%L): %m%n</Property>
</Properties>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="${PATTERN}" />
</Console>
</Appenders>
<Loggers>
<Root level="TRACE">
<AppenderRef ref="STDOUT" />
</Root>
</Loggers>
</Configuration>
Generally speaking, you should never need to switch logging implementations; Logback should suit you fine. However, if you decide that you’d rather use Log4j or Log4j2, you’ll need to change your dependencies to include the appropriate starter for the logging implementation you want to use and to exclude Logback.
Spring Boot in Action
Swapping out Logback for Log4j2 in Gradle
Exclude the default logging
configurations {
all*.exclude group:'org.springframework.boot',
module:'spring-boot-starter-logging'
}
Add Log4j2 logging
compile("org.springframework.boot:spring-boot-starter-log4j2")
You can find details of spring-boot-starter-log4j2 dependency version that is provided by Spring Boot here.
I have met the similar problem. The version of log4j-api and log4j-core have to match (and ClassNotFound is a strange exception here). As you have said in comment, you have found log4j-core-2.7.jar, but I may guess your log4j-api is in version of 2.8.2 as your above description shows.
Check your dependency, remove old version of log4j-core and add new version should fix the problem.
This exception is printed to System.out because the class is not on the classpath of Spring's boot loader. But this is not the cause of logging not working or not using the specified configuration file.
It's a Spring Boot Gradle plugin issue. It should add Log4j to the boot loader classpath when it detects a dependency on Log4j.
I added Logback to my Spring Boot project and it works when writing in files or standard output. Now I would like to send log emails, but if I try to configure the SMTPAppender, I get the following error:
Logging system failed to initialize using configuration from
'logback-spring.xml' java.lang.IllegalStateException: Logback
configuration error detected: ERROR in
ch.qos.logback.core.joran.action.AppenderAction - Could not create an
Appender of type [ch.qos.logback.classic.net.SMTPAppender].
ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
ch.qos.logback.core.joran.spi.Interpreter#8:76 - ActionException in
Action for tag [appender]
ch.qos.logback.core.joran.spi.ActionException:
ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an
appender named [EMAIL]. Did you define it below instead of above in
the configuration file? ERROR in
ch.qos.logback.core.joran.action.AppenderRefAction - See
http://logback.qos.ch/codes.html#appender_order for more details. at
org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:162)
at
org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)
at
org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:56)
at
org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:115)
at
org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:308)
at
org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:276)
at
org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
at
org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:212)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at
org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:73)
at
org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at
org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:336)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at
org.lh.cfpappserver.CfpAppServerApplication.main(CfpAppServerApplication.java:10)
Exception in thread "main" java.lang.IllegalStateException:
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not
create an Appender of type [ch.qos.logback.classic.net.SMTPAppender].
ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
ch.qos.logback.core.joran.spi.Interpreter#8:76 - ActionException in
Action for tag [appender]
ch.qos.logback.core.joran.spi.ActionException:
ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an
appender named [EMAIL]. Did you define it below instead of above in
the configuration file? ERROR in
ch.qos.logback.core.joran.action.AppenderRefAction - See
http://logback.qos.ch/codes.html#appender_order for more details. at
org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:315)
at
org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:276)
at
org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
at
org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:212)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at
org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:73)
at
org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at
org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:336)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at
org.lh.cfpappserver.CfpAppServerApplication.main(CfpAppServerApplication.java:10)
Caused by: java.lang.IllegalStateException: Logback configuration
error detected: ERROR in
ch.qos.logback.core.joran.action.AppenderAction - Could not create an
Appender of type [ch.qos.logback.classic.net.SMTPAppender].
ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
ch.qos.logback.core.joran.spi.Interpreter#8:76 - ActionException in
Action for tag [appender]
ch.qos.logback.core.joran.spi.ActionException:
ch.qos.logback.core.util.DynamicClassLoadingException: Failed to
instantiate type ch.qos.logback.classic.net.SMTPAppender ERROR in
ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an
appender named [EMAIL]. Did you define it below instead of above in
the configuration file? ERROR in
ch.qos.logback.core.joran.action.AppenderRefAction - See
http://logback.qos.ch/codes.html#appender_order for more details. at
org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:162)
at
org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:66)
at
org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:56)
at
org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:115)
at
org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:308)
... 13 more
This is my configuration in logback-spring.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
<include resource="org/springframework/boot/logging/logback/file-appender.xml"/>
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<asynchronousSending>false</asynchronousSending>
<smtpHost>smtp.gmail.com</smtpHost>
<to>my email</to>
<from>my email</from>
<username>xxx</username>
<password>xxx</password>
<subject>%logger{20} - %m</subject>
<layout class="ch.qos.logback.classic.html.HTMLLayout"/>
<cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker">
<bufferSize>1</bufferSize>
</cyclicBufferTracker>
<starttls>true</starttls>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<filter class="org.lh.cfpappserver.util.StdOutFilter"/>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="FILE"/>
<appender-ref ref="EMAIL"/>
<appender-ref ref="STDOUT"/>
</root>
</configuration>
What's wrong in my configuration preventing the application to start?
I've got a Spring Boot command line application using Spring Integration. The application is running within a service wrapper.
At start up, everything seems to run smoothly with no exceptions. However, if I drop a file in the observed directory nothing triggers the inbound-channel-adapter.
Is it at all possible the service wrapper is causing the polling to not run?
UPDATE
I added a logback.xml configuration
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.springframework.integration" level="DEBUG">
<appender-ref ref="STDOUT" />
</logger>
</configuration>
But now the log is not receiving any input with this config. STDOUT works fine without the config. Makes is difficult to enable DEBUG for the integration package.
I based my wrapper on this project
UPDATE #2
I finally got logging working. I had a mistake in assuming it was not a ERROR level issue.
13:29:52.925 [task-scheduler-10] ERROR o.s.i.handler.LoggingHandler - org.springframework.messaging.MessagingException: The path [\\server\sharepath] does not denote a properly accessible directory.
at org.springframework.integration.file.DefaultDirectoryScanner.listFiles(DefaultDirectoryScanner.java:83)
at org.springframework.integration.file.FileReadingMessageSource.scanInputDirectory(FileReadingMessageSource.java:293)
at org.springframework.integration.file.FileReadingMessageSource.receive(FileReadingMessageSource.java:272)
at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:175)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:224)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:57)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:176)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:173)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:330)
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:324)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The issue is that the network path cannot be determined if accessible by Java/Spring.
13:29:52.925 [task-scheduler-10] ERROR o.s.i.handler.LoggingHandler -
org.springframework.messaging.MessagingException: The path
[\server\sharepath] does not denote a properly accessible directory.
I'm using Log4j version 2.1 (the latest stable version) and trying to use a Syslog appender to log to a syslog server. I'm using the configuration given at their official site (http://logging.apache.org/log4j/2.x/manual/appenders.html#SyslogAppender):
<Syslog name="RFC5424" format="RFC5424" host="localhost" port="514"
protocol="UDP" appName="MyApp" includeMDC="true"
facility="LOCAL0" enterpriseNumber="18060" newLine="true"
messageId="Audit" id="App"/>
When I start my app and do a LogManager.getLogger(), I get an error (stack trace bellow), so, before I report an error to their bug tracker, am I doing something wrong?
014-11-17 18:26:23,640 ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.appender.SyslogAppender for element Syslog. java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:766)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:706)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:698)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:358)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:426)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:408)
at Log.<clinit>(Log.java:7)
Caused by: java.lang.IllegalArgumentException: No structured id name was supplied
at org.apache.logging.log4j.message.StructuredDataId.<init>(StructuredDataId.java:92)
at org.apache.logging.log4j.core.layout.Rfc5424Layout.<init>(Rfc5424Layout.java:139)
at org.apache.logging.log4j.core.layout.Rfc5424Layout.createLayout(Rfc5424Layout.java:657)
at org.apache.logging.log4j.core.appender.SyslogAppender.createAppender(SyslogAppender.java:133)
... 19 more
You need to include the mdcId attribute. e.g.:
<Syslog name="RFC5424" format="RFC5424" host="localhost" port="514"
protocol="UDP" appName="MyApp" mdcId="mdc" includeMDC="true"
facility="LOCAL0" enterpriseNumber="18060" newLine="true"
messageId="Audit" id="App"/>