Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LOG4J2-3565] Fix RollingRandomAccessFileAppender with DirectWriteRol… #987

Merged
merged 1 commit into from Aug 4, 2022

Conversation

dafengsu7
Copy link
Contributor

@dafengsu7 dafengsu7 commented Jul 30, 2022

Fixs LOG4J2-3565
When you want split the log into different directories by period (day, hour, minute, etc.), and use
RollingRandomAccessFileAppender with a DirectWrite rollover, the config should be:

<RollingRandomAccessFile name="RollingFile"  filePattern="${baseDir}/%d{s}/%d{s}.log">
    <PatternLayout header= "${LOG_HEADER}">
        <Pattern>${LOG_PATTERN}</Pattern>
    </PatternLayout>
    <Policies>
        <TimeBasedTriggeringPolicy/>
    </Policies>
</RollingRandomAccessFile>

At that time when the first log of each directory try to create, console shows;

2022-07-31 03:17:44,009 main ERROR RollingRandomAccessFileManager target/rolling-random-direct-switch-director/%d{s}/%d{s}.log Failed to create file after rollover: java.io.FileNotFoundException: target/rolling-random-direct-switch-director/44/44.log (No such file or directory) java.io.FileNotFoundException: target/rolling-random-direct-switch-director/44/44.log (No such file or directory)

Apparently the directory has not been created when the file is creating

@dafengsu7 dafengsu7 force-pushed the LOG4J2-3565 branch 2 times, most recently from 19ffab4 to fa46f0c Compare July 31, 2022 19:16
@dafengsu7 dafengsu7 requested a review from ppkarwasz July 31, 2022 20:33
Copy link
Contributor

@ppkarwasz ppkarwasz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@dafengsu7
Copy link
Contributor Author

dafengsu7 commented Aug 2, 2022

Hi, @garydgregory @carterkozak , Please take some time to review this PR, Thanks!😄

@dafengsu7
Copy link
Contributor Author

dafengsu7 commented Aug 2, 2022

Looks good to me.
Is there anything else I need to do? Sorry, my English may not be very good.😅

@ppkarwasz
Copy link
Contributor

Is there anything else I need to do? Sorry, my English may not be very good?sweat_smile

@Dafengsu: you can add an entry to src/changes/changes.xml. Beside that I'll wait a couple of days for other maintainers to get the chance to review your PR and I'll merge it.

Thank you for your contribution.

@dafengsu7
Copy link
Contributor Author

Is there anything else I need to do? Sorry, my English may not be very good?sweat_smile

@Dafengsu: you can add an entry to src/changes/changes.xml. Beside that I'll wait a couple of days for other maintainers to get the chance to review your PR and I'll merge it.

Thank you for your contribution.

@ppkarwasz I see, thank you!

…loverStrategy can't create the first log file of different directory.
@dafengsu7
Copy link
Contributor Author

Is there anything else I need to do? Sorry, my English may not be very good?sweat_smile

@Dafengsu: you can add an entry to src/changes/changes.xml. Beside that I'll wait a couple of days for other maintainers to get the chance to review your PR and I'll merge it.

Thank you for your contribution.

Had add an entry to src/changes/changes.xml, may need re-run workflows.

@ppkarwasz ppkarwasz merged commit 28efddb into apache:release-2.x Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants