Hello logback community,
I stumbled over following situation with the TimeBasedRollingPolicy:
- I have a short running application with following appender configuration
<appender name="R" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logfiles.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>9</maxHistory>
</rollingPolicy>
[some other config]
</appender>
- The log rotation never occured as the application is only short-running and never over midnight. I had missed adding the <cleanHistoryOnStart>true</cleanHistoryOnStart> to the configuration - would probably worth a bit more documentation as this clean flag is described last and therefore could easily be missed on http://logback.qos.ch/manual/appenders.html
- Now I already have a lot of logfiles in my directory and the TimeBasedArchiveRemover seems only to remove one file - Is this intended and why?
Regards
Manuel Oddoy
Disclaimer:
Bitte beachten Sie: die obige Mitteilung ist ausschließlich für die in den
Adresszeilen benannten Personen bestimmt und enthält möglicherweise
vertrauliche Informationen. Sollten Sie diese Nachricht fälschlicherweise
erhalten haben, informieren Sie bitte den Absender. Bitte löschen Sie
die Nachricht und sehen Sie davon ab, die Inhalte zu nutzen,
aufzubewahren, weiterzuleiten oder zu reproduzieren.
Virenschutz:
Unser Unternehmen verfügt über eine funktionierende Anti-Viren-
Software und prüft jede abgesendete E-Mail und deren Anhänge auf
Viren. Trotzdem können wir nicht garantieren, dass die E-Mail virenfrei
ist und übernehmen keine Haftung für Schäden, die aus Viren entstehen.
Hinweis zum Datenschutz:
Die Informationen nach Art. 13 und 14 DSGVO finden Sie unter
"www.kvb.de/datenschutz"
I'm trying to create a console appender that uses a custom pattern and a
custom conversion rule to run the logback logs through the DataConverter
class. I can see in the logs that the new conversion rule gets created but
the logs get dropped after that point. I assume some setup in the below
code is not correct but I'm not sure where I'm going wrong.
ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>()
appender.setName("consoleAppender")
RuleStore rs = new SimpleRuleStore(context)
Interpreter interpreter = new Interpreter(context, rs, new ElementPath())
InterpretationContext interpretationContext =
interpreter.getInterpretationContext()
interpretationContext.setContext(context)
AttributesImpl attributes = new AttributesImpl()
attributes.addAttribute("","","conversionWord", "", "msgMask")
attributes.addAttribute("","","converterClass", "",
"com.x.logging.library.DataConverter")
ConversionRuleAction conversionRule = new ConversionRuleAction()
conversionRule.setContext(context)
conversionRule.begin(interpretationContext, conversionWord, attributes)
PatternLayoutEncoder encoder = new PatternLayoutEncoder()
encoder.setContext(context)
encoder.setPattern('-%clr(%d{-yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(-%5p)
%clr(-){magenta} %clr(---){faint} %clr([%t]){faint}
%clr(%-40.40logger{39}){cyan} %clr(:){faint} %msgMask(%msg) %n')
encoder.start()
appender.setEncoder(encoder)
appender.setContext(context)
appender.start()
//the appender is later added to the logger
I created a question in StackOverflow about this as well:
https://stackoverflow.com/q/66768278/7371030?sem=2
Please let me know if you have any examples of this setup or if you can
pinpoint where I’m going wrong.
Thank you,
Jennifer
This e-mail and any files transmitted with it are confidential and are
solely for the use of the addressee. It may contain material that is
legally privileged, proprietary or subject to copyright belonging to the
sender and its affiliates, and it may be subject to protection under
federal or state law. If you are not the intended recipient, you are
notified that any use of this material is strictly prohibited. If you
received this transmission in error, please contact the sender immediately
by replying to this e-mail and delete the material from your system. The
sender may archive e-mails, which may be accessed by authorized persons and
may be produced to other parties, including public authorities, in
compliance with applicable laws.