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 logs in json #901

Closed
gabriel-suela opened this issue Nov 11, 2024 · 2 comments
Closed

Log4j2 logs in json #901

gabriel-suela opened this issue Nov 11, 2024 · 2 comments
Labels
question User questions. Neither a bug nor feature request.

Comments

@gabriel-suela
Copy link

How can i change the settings for log4j2.properties? Currently im trying to change in the securityconfig-secret :

  - apiVersion: v1
    kind: Secret
    metadata:
      name: securityconfig-secret
    stringData:
      log4j2.properties: |-
        appender.console.type = Console
        appender.console.name = console
        appender.console.layout.type = OpenSearchJsonLayout
        appender.console.layout.type_name = json_logger

        rootLogger.level = info
        rootLogger.appenderRef.console.ref = console

but when i check the log4j2.properties in the container the settings do not change.

[opensearch@opensearch-cluster-masters-0 config]$ cat log4j2.properties
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

status = error

appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n

rootLogger.level = info
rootLogger.appenderRef.console.ref = console
@gabriel-suela gabriel-suela added bug Something isn't working untriaged Issues that have not yet been triaged labels Nov 11, 2024
@swoehrl-mw
Copy link
Collaborator

Hi @gabriel-suela. The securityconfig-secret is, as the name implies, only for the securityconfig, so adding log4j properties there will have no effect.
There is currently no dedicated way to provide a custom log4j2.properties file, but you can mount your own file using the additional volumes feature.

@swoehrl-mw swoehrl-mw added question User questions. Neither a bug nor feature request. and removed bug Something isn't working untriaged Issues that have not yet been triaged labels Nov 12, 2024
@swoehrl-mw swoehrl-mw changed the title [BUG] Log4j2 logs in json Log4j2 logs in json Nov 12, 2024
@gabriel-suela
Copy link
Author

@swoehrl-mw ty for the information.
for anyone in the future that will come here:

general:
    additionalVolumes:
      - name: log4j2-properties
        path: /usr/share/opensearch/config/log4j2.properties
        subPath: log4j2.properties
        configMap:
          name: log4j2-properties
        restartPods: true

configMap:

  - apiVersion: v1
    kind: ConfigMap
    metadata:
      name: log4j2-properties
    data:
      log4j2.properties: |-
        appender.console.type = Console
        appender.console.name = console
        appender.console.layout.type = OpenSearchJsonLayout
        appender.console.layout.type_name = json_logger
        rootLogger.level = info
        rootLogger.appenderRef.console.ref = console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question User questions. Neither a bug nor feature request.
Projects
Status: ✅ Done
Development

No branches or pull requests

2 participants