You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Robert Munteanu <ro...@apache.org> on 2021/01/27 14:12:43 UTC

Re: Sling Log Rotation Pattern '.'yyyy-MM-dd-a

Hi Yonit,

On Fri, 2021-01-22 at 21:00 +0000, Yonit David wrote:
> Hello!
> 
> Has anyone been successful in getting the sling log rotation pattern
> for twice a day - at noon and at midnight to actually work?  '.'yyyy-
> MM-dd-a "
> 
> 
> Other patterns work as expected, but this one seems to just rotate
> once a day at midnight with the addition of AM or PM on the filepath
> instead of actually generating 2 per day.

I haven't tried it myself. Can you share your configuration? Maybe
someone can spot something there. And FWIW, Sling logging configuration
is based on logback [1], so if it works there it should with Sling as
well.

Thanks,
Robert

[1]: https://logback.qos.ch/


Re: Sling Log Rotation Pattern '.'yyyy-MM-dd-a

Posted by Bob Paulin <bo...@bobpaulin.com>.
On 2/3/2021 2:34 PM, Yonit David wrote:
> -----Original Message-----
> From: Bob Paulin <bo...@bobpaulin.com>
> Sent: Wednesday, February 3, 2021 1:27 PM
> To: users@sling.apache.org
> Subject: Re: Sling Log Rotation Pattern '.'yyyy-MM-dd-a
>
> Warning External Email:
>
>
> Hi Yonit,
>
> On 1/27/2021 10:19 AM, Robert Munteanu wrote:
>> Hi Yonit,
>>
>> On Wed, 2021-01-27 at 15:51 +0000, Yonit David wrote:
>>> Hi Robert,
>>> Sorry about that.  Does this work?
>>> <?xml version="1.0" encoding="UTF-8"?> <jcr:root
>>> xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
>>> xmlns:jcr="http://www.jcp.org/jcr/1.0"
>>>       jcr:primaryType="sling:OsgiConfig"
>>>       org.apache.sling.commons.log.file="logs/error.log"
>>>       org.apache.sling.commons.log.file.number="5"
>>>       org.apache.sling.commons.log.file.size="'.'yyyy-MM-dd-a"/>
>> Yes :-)
>>
>> I followed the code paths and found out that we are passing the
>> parameter to the logback TimeBasedRollingPolicy, see [1].
>>
>> I don't see anything incorrect here, so not sure what we can do. I
>> could think of a couple of things you can try to sort this out
>>
>> a. Start with logback in debug mode by adding -Dlogback.debug=true to
>> your launch script and see if the pattern used matches your
>> expectations, e.g. "Configured TimeBasedRollingPolicy with pattern
>> ..." or if you spot something else going wrong.
>>
>> b. Try and configure a plain Logback application with the log rotation
>> pattern and see if that works.
>>
>> Hope this helps,
>> Robert
>>
>> P.S. It would make the conversation easier to follow for me and others
>> if you would use bottom-posting [2] when replying to emails. Thanks!
>>
>> [1]:
>> https://github.com/apache/sling-org-apache-sling-commons-log/blob/c7d5
>> ac9b2b1ddaae48f3d160b6b001b9f9428059/src/main/java/org/apache/sling/co
>> mmons/log/logback/internal/LogWriter.java#L200-L211
>> [2]: https://en.wikipedia.org/wiki/Posting_style#Bottom-posting
>>
> Looks like the problem might be in logback itself.  The HALF_DAY is a supported value for the period but the it's completely absent from the code that controls the triggering logic [1].  Might require an enhancement/bug request to logback rather than sling.
>
> - Bob
>
> [1]
> https://github.com/qos-ch/logback/blob/bbc783e6d68482abe8e7dff0d06708175e971b91/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java#L226
>
>
>
> Robert,
> Sorry about the top-posting.  I hope I'm doing it correctly this time.
>
> Bob,
> Thank you so much!  You are right!  HALF_DAY is completely missing here.  How would I go about submitting this request?
> Thanks
> Yonit
>
> public long periodBarriersCrossed(long start, long end) {
>          if (start > end)
>              throw new IllegalArgumentException("Start cannot come before end");
>
>          long startFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(start, getTimeZone());
>          long endFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(end, getTimeZone());
>
>          long diff = endFloored - startFloored;
>
>          switch (periodicityType) {
>
>          case TOP_OF_MILLISECOND:
>              return diff;
>          case TOP_OF_SECOND:
>              return diff / MILLIS_IN_ONE_SECOND;
>          case TOP_OF_MINUTE:
>              return diff / MILLIS_IN_ONE_MINUTE;
>          case TOP_OF_HOUR:
>              return diff / MILLIS_IN_ONE_HOUR;
>          case TOP_OF_DAY:
>              return diff / MILLIS_IN_ONE_DAY;
>          case TOP_OF_WEEK:
>              return diff / MILLIS_IN_ONE_WEEK;
>          case TOP_OF_MONTH:
>              return diffInMonths(start, end);
>          default:
>              throw new IllegalStateException("Unknown periodicity type.");
>          }
>      }

The logback project is not an apache project so I'm not as familiar with 
their processes but this page [1] seems to have all the info for subbing 
a bug report.   I'd be sure to include your configuration details or 
even better a JUnit.  There appears to be a junit class that you might 
be able to start with [2]

Good Luck!

- Bob

[1] http://logback.qos.ch/bugreport.html

[2] 
https://github.com/qos-ch/logback/blob/master/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/RollingCalendarTest.java


RE: Sling Log Rotation Pattern '.'yyyy-MM-dd-a

Posted by Yonit David <Yo...@anixter.com>.
-----Original Message-----
From: Bob Paulin <bo...@bobpaulin.com> 
Sent: Wednesday, February 3, 2021 1:27 PM
To: users@sling.apache.org
Subject: Re: Sling Log Rotation Pattern '.'yyyy-MM-dd-a

Warning External Email:


Hi Yonit,

On 1/27/2021 10:19 AM, Robert Munteanu wrote:
> Hi Yonit,
>
> On Wed, 2021-01-27 at 15:51 +0000, Yonit David wrote:
>> Hi Robert,
>> Sorry about that.  Does this work?
>> <?xml version="1.0" encoding="UTF-8"?> <jcr:root 
>> xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
>> xmlns:jcr="http://www.jcp.org/jcr/1.0"
>>      jcr:primaryType="sling:OsgiConfig"
>>      org.apache.sling.commons.log.file="logs/error.log"
>>      org.apache.sling.commons.log.file.number="5"
>>      org.apache.sling.commons.log.file.size="'.'yyyy-MM-dd-a"/>
> Yes :-)
>
> I followed the code paths and found out that we are passing the 
> parameter to the logback TimeBasedRollingPolicy, see [1].
>
> I don't see anything incorrect here, so not sure what we can do. I 
> could think of a couple of things you can try to sort this out
>
> a. Start with logback in debug mode by adding -Dlogback.debug=true to 
> your launch script and see if the pattern used matches your 
> expectations, e.g. "Configured TimeBasedRollingPolicy with pattern 
> ..." or if you spot something else going wrong.
>
> b. Try and configure a plain Logback application with the log rotation 
> pattern and see if that works.
>
> Hope this helps,
> Robert
>
> P.S. It would make the conversation easier to follow for me and others 
> if you would use bottom-posting [2] when replying to emails. Thanks!
>
> [1]: 
> https://github.com/apache/sling-org-apache-sling-commons-log/blob/c7d5
> ac9b2b1ddaae48f3d160b6b001b9f9428059/src/main/java/org/apache/sling/co
> mmons/log/logback/internal/LogWriter.java#L200-L211
> [2]: https://en.wikipedia.org/wiki/Posting_style#Bottom-posting
>
Looks like the problem might be in logback itself.  The HALF_DAY is a supported value for the period but the it's completely absent from the code that controls the triggering logic [1].  Might require an enhancement/bug request to logback rather than sling.

- Bob

[1]
https://github.com/qos-ch/logback/blob/bbc783e6d68482abe8e7dff0d06708175e971b91/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java#L226



Robert,
Sorry about the top-posting.  I hope I'm doing it correctly this time.

Bob,
Thank you so much!  You are right!  HALF_DAY is completely missing here.  How would I go about submitting this request?
Thanks
Yonit

public long periodBarriersCrossed(long start, long end) {
        if (start > end)
            throw new IllegalArgumentException("Start cannot come before end");

        long startFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(start, getTimeZone());
        long endFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(end, getTimeZone());

        long diff = endFloored - startFloored;

        switch (periodicityType) {

        case TOP_OF_MILLISECOND:
            return diff;
        case TOP_OF_SECOND:
            return diff / MILLIS_IN_ONE_SECOND;
        case TOP_OF_MINUTE:
            return diff / MILLIS_IN_ONE_MINUTE;
        case TOP_OF_HOUR:
            return diff / MILLIS_IN_ONE_HOUR;
        case TOP_OF_DAY:
            return diff / MILLIS_IN_ONE_DAY;
        case TOP_OF_WEEK:
            return diff / MILLIS_IN_ONE_WEEK;
        case TOP_OF_MONTH:
            return diffInMonths(start, end);
        default:
            throw new IllegalStateException("Unknown periodicity type.");
        }
    }

Re: Sling Log Rotation Pattern '.'yyyy-MM-dd-a

Posted by Bob Paulin <bo...@bobpaulin.com>.
Hi Yonit,

On 1/27/2021 10:19 AM, Robert Munteanu wrote:
> Hi Yonit,
>
> On Wed, 2021-01-27 at 15:51 +0000, Yonit David wrote:
>> Hi Robert,
>> Sorry about that.  Does this work?
>> <?xml version="1.0" encoding="UTF-8"?>
>> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
>> xmlns:jcr="http://www.jcp.org/jcr/1.0"
>>      jcr:primaryType="sling:OsgiConfig"
>>      org.apache.sling.commons.log.file="logs/error.log"
>>      org.apache.sling.commons.log.file.number="5"
>>      org.apache.sling.commons.log.file.size="'.'yyyy-MM-dd-a"/>
> Yes :-)
>
> I followed the code paths and found out that we are passing the
> parameter to the logback TimeBasedRollingPolicy, see [1].
>
> I don't see anything incorrect here, so not sure what we can do. I
> could think of a couple of things you can try to sort this out
>
> a. Start with logback in debug mode by adding -Dlogback.debug=true to
> your launch script and see if the pattern used matches your
> expectations, e.g. "Configured TimeBasedRollingPolicy with pattern
> ..." or if you spot something else going wrong.
>
> b. Try and configure a plain Logback application with the log rotation
> pattern and see if that works.
>
> Hope this helps,
> Robert
>
> P.S. It would make the conversation easier to follow for me and others
> if you would use bottom-posting [2] when replying to emails. Thanks!
>
> [1]: https://github.com/apache/sling-org-apache-sling-commons-log/blob/c7d5ac9b2b1ddaae48f3d160b6b001b9f9428059/src/main/java/org/apache/sling/commons/log/logback/internal/LogWriter.java#L200-L211
> [2]: https://en.wikipedia.org/wiki/Posting_style#Bottom-posting
>
Looks like the problem might be in logback itself.  The HALF_DAY is a 
supported value for the period but the it's completely absent from the 
code that controls the triggering logic [1].  Might require an 
enhancement/bug request to logback rather than sling.

- Bob

[1] 
https://github.com/qos-ch/logback/blob/bbc783e6d68482abe8e7dff0d06708175e971b91/logback-core/src/main/java/ch/qos/logback/core/rolling/helper/RollingCalendar.java#L226



Re: Sling Log Rotation Pattern '.'yyyy-MM-dd-a

Posted by Robert Munteanu <ro...@apache.org>.
Hi Yonit,

On Wed, 2021-01-27 at 15:51 +0000, Yonit David wrote:
> 
> Hi Robert,
> Sorry about that.  Does this work?
> <?xml version="1.0" encoding="UTF-8"?>
> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
> xmlns:jcr="http://www.jcp.org/jcr/1.0"
>     jcr:primaryType="sling:OsgiConfig"
>     org.apache.sling.commons.log.file="logs/error.log"
>     org.apache.sling.commons.log.file.number="5"
>     org.apache.sling.commons.log.file.size="'.'yyyy-MM-dd-a"/>

Yes :-)

I followed the code paths and found out that we are passing the
parameter to the logback TimeBasedRollingPolicy, see [1].

I don't see anything incorrect here, so not sure what we can do. I
could think of a couple of things you can try to sort this out

a. Start with logback in debug mode by adding -Dlogback.debug=true to
your launch script and see if the pattern used matches your
expectations, e.g. "Configured TimeBasedRollingPolicy with pattern 
..." or if you spot something else going wrong.

b. Try and configure a plain Logback application with the log rotation
pattern and see if that works.

Hope this helps,
Robert

P.S. It would make the conversation easier to follow for me and others
if you would use bottom-posting [2] when replying to emails. Thanks!

[1]: https://github.com/apache/sling-org-apache-sling-commons-log/blob/c7d5ac9b2b1ddaae48f3d160b6b001b9f9428059/src/main/java/org/apache/sling/commons/log/logback/internal/LogWriter.java#L200-L211
[2]: https://en.wikipedia.org/wiki/Posting_style#Bottom-posting


RE: Sling Log Rotation Pattern '.'yyyy-MM-dd-a

Posted by Yonit David <Yo...@anixter.com>.
Hi Robert,
Sorry about that.  Does this work?
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="sling:OsgiConfig"
    org.apache.sling.commons.log.file="logs/error.log"
    org.apache.sling.commons.log.file.number="5"
    org.apache.sling.commons.log.file.size="'.'yyyy-MM-dd-a"/>

Thanks
Yonit

-----Original Message-----
From: Robert Munteanu <ro...@apache.org> 
Sent: Wednesday, January 27, 2021 9:49 AM
To: users@sling.apache.org
Subject: Re: Sling Log Rotation Pattern '.'yyyy-MM-dd-a

Warning External Email:


Hi Yonit,

On Wed, 2021-01-27 at 15:43 +0000, Yonit David wrote:
> Thank you so much for your reply.  Here is my configuration:
>
> [cid:image002.jpg@01D6F490.D200BCE0]

I am not able to see the image. Can you please resend, in plain text if at all possible?

Our mailing list viewer has the same problem [1]

Thanks,
Robert

[1]:
https://lists.apache.org/thread.html/r76a17367616515887927a81d410e9cc602ef28bb260b310462df74b1%40%3Cusers.sling.apache.org%3E


Re: Sling Log Rotation Pattern '.'yyyy-MM-dd-a

Posted by Robert Munteanu <ro...@apache.org>.
Hi Yonit,

On Wed, 2021-01-27 at 15:43 +0000, Yonit David wrote:
> Thank you so much for your reply.  Here is my configuration:
> 
> [cid:image002.jpg@01D6F490.D200BCE0]

I am not able to see the image. Can you please resend, in plain text if
at all possible?

Our mailing list viewer has the same problem [1]

Thanks,
Robert

[1]:
https://lists.apache.org/thread.html/r76a17367616515887927a81d410e9cc602ef28bb260b310462df74b1%40%3Cusers.sling.apache.org%3E


RE: Sling Log Rotation Pattern '.'yyyy-MM-dd-a

Posted by Yonit David <Yo...@anixter.com>.
Robert,

Thank you so much for your reply.  Here is my configuration:

[cid:image002.jpg@01D6F490.D200BCE0]

Thanks

Yonit



-----Original Message-----
From: Robert Munteanu <ro...@apache.org>
Sent: Wednesday, January 27, 2021 8:13 AM
To: users@sling.apache.org
Subject: Re: Sling Log Rotation Pattern '.'yyyy-MM-dd-a



Warning External Email:





Hi Yonit,



On Fri, 2021-01-22 at 21:00 +0000, Yonit David wrote:

> Hello!

>

> Has anyone been successful in getting the sling log rotation pattern

> for twice a day - at noon and at midnight to actually work?  '.'yyyy-

> MM-dd-a "

>

>

> Other patterns work as expected, but this one seems to just rotate

> once a day at midnight with the addition of AM or PM on the filepath

> instead of actually generating 2 per day.



I haven't tried it myself. Can you share your configuration? Maybe someone can spot something there. And FWIW, Sling logging configuration is based on logback [1], so if it works there it should with Sling as well.



Thanks,

Robert



[1]: https://logback.qos.ch/