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

configure logbook with NoSql appenders #339

Closed
amr-fathi opened this issue Aug 30, 2018 · 1 comment
Closed

configure logbook with NoSql appenders #339

amr-fathi opened this issue Aug 30, 2018 · 1 comment

Comments

@amr-fathi
Copy link

amr-fathi commented Aug 30, 2018

Hi,

So I'm still pretty new to logbook. And I would like to have it configured to dump log messages into a NoSQL (specifically mongodb) within a spring-boot application.

Accordingly, I added the following lines into my application.yml:

logbook:
     exclude:
        - /health
        - /admin/**
        - /swagger-ui.html
        - /swagger-resources/**
        - /webjars/**
        - /configuration/security/**
        - /swagger-resources/**
        - /configuration/ui/**
        - /v2/api-docs/**
        - /csrf/**
    filter.enabled: true
    format.style: http
    obfuscate:
        headers:
            - Authorization
            - X-Secret
        parameters:
            - access_token
            - password
    write:
        category: http.wire-log
        level: INFO
        chunk-size: 1000

and the following is how log4j2 is configured:

<Configuration monitorInterval="60">
    <Appenders>
        <NoSql name="databaseAppender">
          <MongoDb2 databaseName="****" collectionName="*****" server="localhost" port="27017" username="" password="" />
        </NoSql>
    </Appenders>
    <Loggers>
        <Logger name="org.apache.http.wire">
            <AppenderRef ref="databaseAppender"/>
        </Logger>
        <Root>
            <AppenderRef ref="databaseAppender"/>
        </Root>
    </Loggers>
</Configuration>

and the following is the list of related dependencies in my pom.xml:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.4.RELEASE</version>
    <relativePath/> 
</parent>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>
    <dependency>
        <groupId>org.zalando</groupId>
        <artifactId>logbook-spring-boot-starter</artifactId>
        <version>1.9.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-mongodb2</artifactId>
        <version>2.11.1</version>
    </dependency>

I tried mixing and matching log levels and so, but nothing seems to work. No matter I do, logs are
directly dumped into console (STDOUT) and nothing goes to mongodb.

Am I missing something?

Thanks in advance

@whiskeysierra
Copy link
Collaborator

Can you share your log4j2.xml?

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

No branches or pull requests

2 participants