Is it possible to confgure log messages from ch.qos.logback using logback.xml?
up vote
0
down vote
favorite
I am successfully using logback for an application, but have been unable to log messages from ch.qos.logback. I am aware that one is unable to log the initial messages (answers below confirm this) and that makes sense. What I don't understand is why I haven't been able to log the messages generated after logback has finished configuring itself.
So, there is no way to tell Logback to direct its own on-startup-log-events to a file appender.
"The first log output by ch.qos.logback can't be redirected using the log configuration because this output happens while Logback reads it's configuration -> hen / egg style problem."
The logback.xml (this exact code will generate ERROR messages from ch.qos.logback.classic.net.SMTPAppender when it fails to login to the email server):
<?xml version="1.0" encoding="UTF-8"?>
<!-- see http://logback.qos.ch/manual/configuration.html -->
<configuration scan="true" debug="true">
<timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</encoder>
</appender>
<appender name="testFile" class="ch.qos.logback.core.FileAppender">
<file> testFile.txt </file>
<append>false</append>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</encoder>
</appender>
<appender name="GMAIL_EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>smtp.gmail.com</smtpHost>
<smtpPort>587</smtpPort>
<asynchronousSending>true</asynchronousSending>
<username>xxx</username>
<password>xxx</password>
<STARTTLS>true</STARTTLS>
<to>xxx</to>
<from>xxx</from>
<subject>Error: %logger{20} - %m</subject>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</layout>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="testFile" />
<appender-ref ref="GMAIL_EMAIL" />
</root>
<logger name="ch.qos.logback" level="DEBUG" >
</logger>
</configuration>
debug console output:
13:05:07,626 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [conflogback.xml] at [file:/C:/OleAppnWorkArea/staging__unity_group14b/conf/logback.xml]
13:05:07,806 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[C:OleAppnWorkAreastaging__unity_group14bconflogback.xml]] every 60 seconds.
13:05:07,806 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
13:05:07,806 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Using current interpretation time, i.e. now, as time reference.
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Adding property to the context with key="bySecond" and value="20181109T130507" to the LOCAL scope
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
13:05:07,882 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
13:05:07,887 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [testFile]
13:05:07,897 |-INFO in ch.qos.logback.core.FileAppender[testFile] - File property is set to [testFile.txt]
13:05:07,899 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.net.SMTPAppender]
13:05:07,910 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [GMAIL_EMAIL]
13:05:07,950 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
13:05:07,950 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
13:05:07,951 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [testFile] to Logger[ROOT]
13:05:07,951 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [GMAIL_EMAIL] to Logger[ROOT]
13:05:07,952 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [ch.qos.logback] to DEBUG
13:05:07,952 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
13:05:07,953 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@481a996b - Registering current configuration as safe fallback point
13:05:07.966 [main] ERROR xxx - error to use for debugging logging~
13:05:07,972 |-INFO in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - SMTPAppender [GMAIL_EMAIL] is tracking [1] buffers
13:05:07,997 |-INFO in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - About to send out SMTP message "Error: xxx - error to use for debugging logging" to [xxx]
13:05:09,019 |-ERROR in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - Error occurred while sending e-mail notification. javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials o27-v6sm5469472wro.24 - gsmtp at javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials o27-v6sm5469472wro.24 - gsmtp
at at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:965)
at at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:876)
at at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:780)
at at javax.mail.Service.connect(Service.java:388)
at at javax.mail.Service.connect(Service.java:246)
at at javax.mail.Service.connect(Service.java:195)
at at javax.mail.Transport.send0(Transport.java:254)
at at javax.mail.Transport.send(Transport.java:124)
at at ch.qos.logback.core.net.SMTPAppenderBase.sendBuffer(SMTPAppenderBase.java:394)
at at ch.qos.logback.core.net.SMTPAppenderBase$SenderRunnable.run(SMTPAppenderBase.java:677)
at at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at at java.lang.Thread.run(Thread.java:748)
testFile.txt only contains:
13:05:07.966 [main] ERROR xxx- error to use for debugging logging~
The messages generated by ch.qos.logback.classic.net.SMTPAppender follow the same pattern as the startup messages and not the pattern I defined in appender STDOUT, suggesting that they are not even using my STDOUT appender. Additionally they are not even appearing in the testFile appender output.
Can anyone shed any light on this, please? I have read the docs and done this testing and am left with no further avenues.
logback
add a comment |
up vote
0
down vote
favorite
I am successfully using logback for an application, but have been unable to log messages from ch.qos.logback. I am aware that one is unable to log the initial messages (answers below confirm this) and that makes sense. What I don't understand is why I haven't been able to log the messages generated after logback has finished configuring itself.
So, there is no way to tell Logback to direct its own on-startup-log-events to a file appender.
"The first log output by ch.qos.logback can't be redirected using the log configuration because this output happens while Logback reads it's configuration -> hen / egg style problem."
The logback.xml (this exact code will generate ERROR messages from ch.qos.logback.classic.net.SMTPAppender when it fails to login to the email server):
<?xml version="1.0" encoding="UTF-8"?>
<!-- see http://logback.qos.ch/manual/configuration.html -->
<configuration scan="true" debug="true">
<timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</encoder>
</appender>
<appender name="testFile" class="ch.qos.logback.core.FileAppender">
<file> testFile.txt </file>
<append>false</append>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</encoder>
</appender>
<appender name="GMAIL_EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>smtp.gmail.com</smtpHost>
<smtpPort>587</smtpPort>
<asynchronousSending>true</asynchronousSending>
<username>xxx</username>
<password>xxx</password>
<STARTTLS>true</STARTTLS>
<to>xxx</to>
<from>xxx</from>
<subject>Error: %logger{20} - %m</subject>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</layout>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="testFile" />
<appender-ref ref="GMAIL_EMAIL" />
</root>
<logger name="ch.qos.logback" level="DEBUG" >
</logger>
</configuration>
debug console output:
13:05:07,626 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [conflogback.xml] at [file:/C:/OleAppnWorkArea/staging__unity_group14b/conf/logback.xml]
13:05:07,806 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[C:OleAppnWorkAreastaging__unity_group14bconflogback.xml]] every 60 seconds.
13:05:07,806 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
13:05:07,806 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Using current interpretation time, i.e. now, as time reference.
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Adding property to the context with key="bySecond" and value="20181109T130507" to the LOCAL scope
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
13:05:07,882 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
13:05:07,887 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [testFile]
13:05:07,897 |-INFO in ch.qos.logback.core.FileAppender[testFile] - File property is set to [testFile.txt]
13:05:07,899 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.net.SMTPAppender]
13:05:07,910 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [GMAIL_EMAIL]
13:05:07,950 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
13:05:07,950 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
13:05:07,951 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [testFile] to Logger[ROOT]
13:05:07,951 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [GMAIL_EMAIL] to Logger[ROOT]
13:05:07,952 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [ch.qos.logback] to DEBUG
13:05:07,952 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
13:05:07,953 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@481a996b - Registering current configuration as safe fallback point
13:05:07.966 [main] ERROR xxx - error to use for debugging logging~
13:05:07,972 |-INFO in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - SMTPAppender [GMAIL_EMAIL] is tracking [1] buffers
13:05:07,997 |-INFO in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - About to send out SMTP message "Error: xxx - error to use for debugging logging" to [xxx]
13:05:09,019 |-ERROR in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - Error occurred while sending e-mail notification. javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials o27-v6sm5469472wro.24 - gsmtp at javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials o27-v6sm5469472wro.24 - gsmtp
at at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:965)
at at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:876)
at at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:780)
at at javax.mail.Service.connect(Service.java:388)
at at javax.mail.Service.connect(Service.java:246)
at at javax.mail.Service.connect(Service.java:195)
at at javax.mail.Transport.send0(Transport.java:254)
at at javax.mail.Transport.send(Transport.java:124)
at at ch.qos.logback.core.net.SMTPAppenderBase.sendBuffer(SMTPAppenderBase.java:394)
at at ch.qos.logback.core.net.SMTPAppenderBase$SenderRunnable.run(SMTPAppenderBase.java:677)
at at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at at java.lang.Thread.run(Thread.java:748)
testFile.txt only contains:
13:05:07.966 [main] ERROR xxx- error to use for debugging logging~
The messages generated by ch.qos.logback.classic.net.SMTPAppender follow the same pattern as the startup messages and not the pattern I defined in appender STDOUT, suggesting that they are not even using my STDOUT appender. Additionally they are not even appearing in the testFile appender output.
Can anyone shed any light on this, please? I have read the docs and done this testing and am left with no further avenues.
logback
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am successfully using logback for an application, but have been unable to log messages from ch.qos.logback. I am aware that one is unable to log the initial messages (answers below confirm this) and that makes sense. What I don't understand is why I haven't been able to log the messages generated after logback has finished configuring itself.
So, there is no way to tell Logback to direct its own on-startup-log-events to a file appender.
"The first log output by ch.qos.logback can't be redirected using the log configuration because this output happens while Logback reads it's configuration -> hen / egg style problem."
The logback.xml (this exact code will generate ERROR messages from ch.qos.logback.classic.net.SMTPAppender when it fails to login to the email server):
<?xml version="1.0" encoding="UTF-8"?>
<!-- see http://logback.qos.ch/manual/configuration.html -->
<configuration scan="true" debug="true">
<timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</encoder>
</appender>
<appender name="testFile" class="ch.qos.logback.core.FileAppender">
<file> testFile.txt </file>
<append>false</append>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</encoder>
</appender>
<appender name="GMAIL_EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>smtp.gmail.com</smtpHost>
<smtpPort>587</smtpPort>
<asynchronousSending>true</asynchronousSending>
<username>xxx</username>
<password>xxx</password>
<STARTTLS>true</STARTTLS>
<to>xxx</to>
<from>xxx</from>
<subject>Error: %logger{20} - %m</subject>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</layout>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="testFile" />
<appender-ref ref="GMAIL_EMAIL" />
</root>
<logger name="ch.qos.logback" level="DEBUG" >
</logger>
</configuration>
debug console output:
13:05:07,626 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [conflogback.xml] at [file:/C:/OleAppnWorkArea/staging__unity_group14b/conf/logback.xml]
13:05:07,806 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[C:OleAppnWorkAreastaging__unity_group14bconflogback.xml]] every 60 seconds.
13:05:07,806 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
13:05:07,806 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Using current interpretation time, i.e. now, as time reference.
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Adding property to the context with key="bySecond" and value="20181109T130507" to the LOCAL scope
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
13:05:07,882 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
13:05:07,887 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [testFile]
13:05:07,897 |-INFO in ch.qos.logback.core.FileAppender[testFile] - File property is set to [testFile.txt]
13:05:07,899 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.net.SMTPAppender]
13:05:07,910 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [GMAIL_EMAIL]
13:05:07,950 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
13:05:07,950 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
13:05:07,951 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [testFile] to Logger[ROOT]
13:05:07,951 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [GMAIL_EMAIL] to Logger[ROOT]
13:05:07,952 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [ch.qos.logback] to DEBUG
13:05:07,952 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
13:05:07,953 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@481a996b - Registering current configuration as safe fallback point
13:05:07.966 [main] ERROR xxx - error to use for debugging logging~
13:05:07,972 |-INFO in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - SMTPAppender [GMAIL_EMAIL] is tracking [1] buffers
13:05:07,997 |-INFO in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - About to send out SMTP message "Error: xxx - error to use for debugging logging" to [xxx]
13:05:09,019 |-ERROR in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - Error occurred while sending e-mail notification. javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials o27-v6sm5469472wro.24 - gsmtp at javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials o27-v6sm5469472wro.24 - gsmtp
at at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:965)
at at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:876)
at at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:780)
at at javax.mail.Service.connect(Service.java:388)
at at javax.mail.Service.connect(Service.java:246)
at at javax.mail.Service.connect(Service.java:195)
at at javax.mail.Transport.send0(Transport.java:254)
at at javax.mail.Transport.send(Transport.java:124)
at at ch.qos.logback.core.net.SMTPAppenderBase.sendBuffer(SMTPAppenderBase.java:394)
at at ch.qos.logback.core.net.SMTPAppenderBase$SenderRunnable.run(SMTPAppenderBase.java:677)
at at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at at java.lang.Thread.run(Thread.java:748)
testFile.txt only contains:
13:05:07.966 [main] ERROR xxx- error to use for debugging logging~
The messages generated by ch.qos.logback.classic.net.SMTPAppender follow the same pattern as the startup messages and not the pattern I defined in appender STDOUT, suggesting that they are not even using my STDOUT appender. Additionally they are not even appearing in the testFile appender output.
Can anyone shed any light on this, please? I have read the docs and done this testing and am left with no further avenues.
logback
I am successfully using logback for an application, but have been unable to log messages from ch.qos.logback. I am aware that one is unable to log the initial messages (answers below confirm this) and that makes sense. What I don't understand is why I haven't been able to log the messages generated after logback has finished configuring itself.
So, there is no way to tell Logback to direct its own on-startup-log-events to a file appender.
"The first log output by ch.qos.logback can't be redirected using the log configuration because this output happens while Logback reads it's configuration -> hen / egg style problem."
The logback.xml (this exact code will generate ERROR messages from ch.qos.logback.classic.net.SMTPAppender when it fails to login to the email server):
<?xml version="1.0" encoding="UTF-8"?>
<!-- see http://logback.qos.ch/manual/configuration.html -->
<configuration scan="true" debug="true">
<timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</encoder>
</appender>
<appender name="testFile" class="ch.qos.logback.core.FileAppender">
<file> testFile.txt </file>
<append>false</append>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</encoder>
</appender>
<appender name="GMAIL_EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>smtp.gmail.com</smtpHost>
<smtpPort>587</smtpPort>
<asynchronousSending>true</asynchronousSending>
<username>xxx</username>
<password>xxx</password>
<STARTTLS>true</STARTTLS>
<to>xxx</to>
<from>xxx</from>
<subject>Error: %logger{20} - %m</subject>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg~%n</Pattern>
</layout>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="testFile" />
<appender-ref ref="GMAIL_EMAIL" />
</root>
<logger name="ch.qos.logback" level="DEBUG" >
</logger>
</configuration>
debug console output:
13:05:07,626 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [conflogback.xml] at [file:/C:/OleAppnWorkArea/staging__unity_group14b/conf/logback.xml]
13:05:07,806 |-INFO in ReconfigureOnChangeFilter{invocationCounter=0} - Will scan for changes in [[C:OleAppnWorkAreastaging__unity_group14bconflogback.xml]] every 60 seconds.
13:05:07,806 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Adding ReconfigureOnChangeFilter as a turbo filter
13:05:07,806 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Using current interpretation time, i.e. now, as time reference.
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.TimestampAction - Adding property to the context with key="bySecond" and value="20181109T130507" to the LOCAL scope
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
13:05:07,816 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
13:05:07,882 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
13:05:07,887 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [testFile]
13:05:07,897 |-INFO in ch.qos.logback.core.FileAppender[testFile] - File property is set to [testFile.txt]
13:05:07,899 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.net.SMTPAppender]
13:05:07,910 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [GMAIL_EMAIL]
13:05:07,950 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
13:05:07,950 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
13:05:07,951 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [testFile] to Logger[ROOT]
13:05:07,951 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [GMAIL_EMAIL] to Logger[ROOT]
13:05:07,952 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [ch.qos.logback] to DEBUG
13:05:07,952 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
13:05:07,953 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@481a996b - Registering current configuration as safe fallback point
13:05:07.966 [main] ERROR xxx - error to use for debugging logging~
13:05:07,972 |-INFO in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - SMTPAppender [GMAIL_EMAIL] is tracking [1] buffers
13:05:07,997 |-INFO in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - About to send out SMTP message "Error: xxx - error to use for debugging logging" to [xxx]
13:05:09,019 |-ERROR in ch.qos.logback.classic.net.SMTPAppender[GMAIL_EMAIL] - Error occurred while sending e-mail notification. javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials o27-v6sm5469472wro.24 - gsmtp at javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials o27-v6sm5469472wro.24 - gsmtp
at at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:965)
at at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:876)
at at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:780)
at at javax.mail.Service.connect(Service.java:388)
at at javax.mail.Service.connect(Service.java:246)
at at javax.mail.Service.connect(Service.java:195)
at at javax.mail.Transport.send0(Transport.java:254)
at at javax.mail.Transport.send(Transport.java:124)
at at ch.qos.logback.core.net.SMTPAppenderBase.sendBuffer(SMTPAppenderBase.java:394)
at at ch.qos.logback.core.net.SMTPAppenderBase$SenderRunnable.run(SMTPAppenderBase.java:677)
at at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at at java.lang.Thread.run(Thread.java:748)
testFile.txt only contains:
13:05:07.966 [main] ERROR xxx- error to use for debugging logging~
The messages generated by ch.qos.logback.classic.net.SMTPAppender follow the same pattern as the startup messages and not the pattern I defined in appender STDOUT, suggesting that they are not even using my STDOUT appender. Additionally they are not even appearing in the testFile appender output.
Can anyone shed any light on this, please? I have read the docs and done this testing and am left with no further avenues.
logback
logback
edited Nov 9 at 16:36
asked Nov 9 at 13:18
beigemartin
11
11
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Logback does not use loggers to report its own log output. Logback's own logs are called "status messages". See documentation on status printing and status listeners
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Logback does not use loggers to report its own log output. Logback's own logs are called "status messages". See documentation on status printing and status listeners
add a comment |
up vote
0
down vote
Logback does not use loggers to report its own log output. Logback's own logs are called "status messages". See documentation on status printing and status listeners
add a comment |
up vote
0
down vote
up vote
0
down vote
Logback does not use loggers to report its own log output. Logback's own logs are called "status messages". See documentation on status printing and status listeners
Logback does not use loggers to report its own log output. Logback's own logs are called "status messages". See documentation on status printing and status listeners
answered Nov 11 at 22:24
Ceki
20k65066
20k65066
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53226459%2fis-it-possible-to-confgure-log-messages-from-ch-qos-logback-using-logback-xml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown