Skip to content

Set permissions for rollover file #2899

Answered by ppkarwasz
StudentGu asked this question in Q&A
Discussion options

You must be logged in to vote

Log4j Core is highly extensible. Since RollingFile does not have a rolledFilePermissions property (see plugin reference for the complete list), you can create your own plugin that does.

You don't even need to implement any append logic, just create a builder that creates a standard RollingFileAppender:

@Plugin(name = "MyRollingFile", category = CATEGORY)
public abstract class MyRollingFileAppender implements Appender {

    @PluginBuilderFactory
    public static Builder newBuilder() {
        return new Builder();
    }

    public static final class Builder extends RollingFileAppender.Builder<Builder> {

        @PluginBuilderAttribute
        private String rollingFilePermissions;

   …

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@ppkarwasz
Comment options

@StudentGu
Comment options

@ppkarwasz
Comment options

Answer selected by StudentGu
@StudentGu
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2894 on August 29, 2024 09:41.