-----Original Message-----
From: Bob Paulin <b...@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.");
        }
    }

Reply via email to