From ashevade at gmail.com Mon Feb 12 19:44:47 2024 From: ashevade at gmail.com (Aniruddha Shevade) Date: Mon, 12 Feb 2024 11:44:47 -0800 Subject: [logback-user] migration from log4j to logback. help with specific log4j.xml property (CronTriggerPolicy> Message-ID: Hello I am trying to migrate a application form log4j to logback. I do have the following property defined in the existing log4j2.xml file, I do not see any such equivalent in the logback.xml. *How do I specify something like a CronTriggerPolicy as shown below?* Any help would be appreciated. log4j2.xml * * Best regards Ani -------------- next part -------------- An HTML attachment was scrubbed... URL: From ceki at qos.ch Mon Feb 12 20:36:00 2024 From: ceki at qos.ch (Ceki Gulcu) Date: Mon, 12 Feb 2024 21:36:00 +0100 Subject: [logback-user] migration from log4j to logback. help with specific log4j.xml property (CronTriggerPolicy> In-Reply-To: References: Message-ID: <603f4ffc-dd20-41e5-a532-c417bb896a97@qos.ch> Hi Ani, Logback does not support cron-like triggering. However, it supports triggering based on a date pattern, e.g "yyyy-MM-dd" The schedule "0 0 * * 1 ?" corresponds to first day of the week at midnight. The pattern "yyyy-ww" corresponds to the same triggering schedule. The link below provides more details: https://logback.qos.ch/manual/appenders.html#tbrpFileNamePattern I hope this helps, -- Ceki Gülcü Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch On 2/12/2024 8:44 PM, Aniruddha Shevade via logback-user wrote: > Hello >  I am trying to migrate a application form log4j to logback. I do have > the following property defined in the existing log4j2.xml file, I do not > see any such equivalent in the logback.xml. > *How do I specify something like a CronTriggerPolicy as shown below?* > Any help would be appreciated. > > log4j2.xml > > filePattern"app.log.%d{yyyyMMdd_HHmmzz}Z.log> > > *     * >     > > > > > Best regards > Ani > From ashevade at gmail.com Mon Feb 12 21:56:53 2024 From: ashevade at gmail.com (Aniruddha Shevade) Date: Mon, 12 Feb 2024 13:56:53 -0800 Subject: [logback-user] migration from log4j to logback. help with specific log4j.xml property (CronTriggerPolicy> In-Reply-To: <603f4ffc-dd20-41e5-a532-c417bb896a97@qos.ch> References: <603f4ffc-dd20-41e5-a532-c417bb896a97@qos.ch> Message-ID: Hello Thanks for the answer. I am still a bit confused. If the logback FileNamePattern is "app.log.%d{yyyyMMdd_HHmmss}Z.log", would this by default mean its going to rollover every second? In other words , does the fileNamePattern define the rollover schedule? You mention using "yyyy-ww" to trigger a weekly Rollover, would this mean the fileName pattern should be made "app.log%d{yyyy-ww}Z.log" ? Is it possible to decouple the Name of the Rolled over log file and the tiriggering of RollOver ? What if Iwant a rollover every week , but the name of the Rolled Over file to have hhmmss as part of it? I Sorry if I have caused confusion here Best Regards Ani On Mon, Feb 12, 2024 at 12:36 PM Ceki Gulcu via logback-user < logback-user at qos.ch> wrote: > Hi Ani, > > Logback does not support cron-like triggering. However, it supports > triggering based on a date pattern, e.g "yyyy-MM-dd" > > The schedule "0 0 * * 1 ?" corresponds to first day of the week at > midnight. The pattern "yyyy-ww" corresponds to the same triggering > schedule. > > The link below provides more details: > > https://logback.qos.ch/manual/appenders.html#tbrpFileNamePattern > > I hope this helps, > > -- > Ceki Gülcü > > Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch > > On 2/12/2024 8:44 PM, Aniruddha Shevade via logback-user wrote: > > Hello > > I am trying to migrate a application form log4j to logback. I do have > > the following property defined in the existing log4j2.xml file, I do not > > see any such equivalent in the logback.xml. > > *How do I specify something like a CronTriggerPolicy as shown below?* > > Any help would be appreciated. > > > > log4j2.xml > > > > > filePattern"app.log.%d{yyyyMMdd_HHmmzz}Z.log> > > > > * * > > > > > > > > > > > > Best regards > > Ani > > > _______________________________________________ > logback-user mailing list > logback-user at qos.ch > https://mailman.qos.ch/cgi-bin/mailman/listinfo/logback-user -------------- next part -------------- An HTML attachment was scrubbed... URL: From ceki at qos.ch Mon Feb 12 22:04:26 2024 From: ceki at qos.ch (Ceki Gulcu) Date: Mon, 12 Feb 2024 23:04:26 +0100 Subject: [logback-user] migration from log4j to logback. help with specific log4j.xml property (CronTriggerPolicy> In-Reply-To: References: <603f4ffc-dd20-41e5-a532-c417bb896a97@qos.ch> Message-ID: <6cadc069-f10c-4ffb-8039-9f7400eac387@qos.ch> Responses inline. On 2/12/2024 10:56 PM, Aniruddha Shevade via logback-user wrote: > Hello >  Thanks for the answer. I am still a bit confused. > If the logback FileNamePattern is "app.log.%d{yyyyMMdd_HHmmss}Z.log", > would this by default mean its going to rollover every second? In other > words , does the fileNamePattern define the rollover schedule? That is correct, the fileNamePattern defines the rollover schedule. > > You mention using "yyyy-ww"  to trigger a weekly Rollover, would this > mean the fileName pattern should be made > "app.log%d{yyyy-ww}Z.log" ?  Yes. However, automatic file compression is enabled if the value of the fileNamePattern option ends with .gz or .zip but not Z. > Is it possible to decouple the Name of the Rolled over log file and the > tiriggering of RollOver ?  What if  Iwant a rollover every week , but > the name of the Rolled Over file to have hhmmss as part of it? I Sorry > if I have caused confusion here Complete decoupling is not possible however you can have multiple %d specifiers. See the link provided earlier. > Best Regards > Ani > -- Ceki Gülcü Sponsoring SLF4J/logback/reload4j at https://github.com/sponsors/qos-ch From kypdkz at gmail.com Wed Feb 14 09:22:13 2024 From: kypdkz at gmail.com (kypdk) Date: Wed, 14 Feb 2024 12:22:13 +0300 Subject: [logback-user] Xml to Java code, logstash encoder Message-ID: Hello Guys I want to create the logstash encoder you see in xml with Java code. But there is no method to set the pattern. Which method should I do? logback/uptLog.log logback/uptLog.%d{yyyy-MM-dd}.log UTF-8 %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %X{requestId} %msg%n%exception{full} net.logstash.logback.encoder.LogstashEncoder logstashEncoder = new LogstashEncoder(); logstashEncoder.setContext(loggerContext); logstashEncoder.start(); Regars -------------- next part -------------- An HTML attachment was scrubbed... URL: From ashevade at gmail.com Thu Feb 29 17:57:47 2024 From: ashevade at gmail.com (Aniruddha Shevade) Date: Thu, 29 Feb 2024 09:57:47 -0800 Subject: [logback-user] Help with FileName and FilePAttern syntax: Message-ID: Hello I am trying to migrate from log4j2 to logback. I am trying to find equivalent syntax for filename and filepatterns in this case log4j2.xml When i use something like this I get an exception saying invalid Repition. I m not sure what the above code was intended to do. 1. How can i convert this fileName to a valid one in logback ? 2. I do understand it will resolve ${env1} properly from environment variables. The "myENv" is being defined in a .properties file being loaded by the application. I have seens examples in logback.xml like what* does the :[myEnv] do here ? Would it resolve to a property set in a .* properties* file?* *ALso not sure what the @ symbol means in the log4j, and if it has any equivalent here?* thanks for any pointers Best Regards Ani -------------- next part -------------- An HTML attachment was scrubbed... URL: