{"record":{"id":"90c63de53a6af5d3","repo":"pinpoint-apm/pinpoint","slug":"loggerbinder-is-already-initialized-90c63d","errorCode":null,"errorMessage":"LoggerBinder is already initialized","messagePattern":"LoggerBinder is already initialized","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agent-module/profiler-logging/src/main/java/com/navercorp/pinpoint/profiler/logging/Log4j2LoggingSystem.java","lineNumber":150,"sourceCode":"            logger.info(\"{} stop\", this.getClass().getSimpleName());\n            this.binder.shutdown();\n            if (loggerContext instanceof LifeCycle) {\n                logger.info(\"{} loggerContext stop\", this.getClass().getSimpleName());\n                ((LifeCycle) loggerContext).stop();\n            }\n        }\n\n    }\n\n\n    private void bindPluginLogFactory(PluginLoggerBinder binder) {\n        final String binderClassName = binder.getClass().getName();\n        PluginLogger pluginLogger = binder.getLogger(binder.getClass().getName());\n        pluginLogger.info(\"PluginLogManager.initialize() bind:{} cl:{}\", binderClassName, binder.getClass().getClassLoader());\n        // Set binder to static PluginLogManager\n        // Should we unset binder at shutdown hook or stop()?\n        if (!PluginLogManager.initialize(binder)) {\n            pluginLogger.warn(\"LoggerBinder is already initialized\");\n        }\n    }\n}\n","sourceCodeStart":132,"sourceCodeEnd":154,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler-logging/src/main/java/com/navercorp/pinpoint/profiler/logging/Log4j2LoggingSystem.java#L132-L154","documentation":"In Log4j2LoggingSystem.bindPluginLogFactory(), if PluginLogManager.initialize(binder) returns false, a binder is already registered, and 'LoggerBinder is already initialized' is warned. The call happens during profiler start; a second initialize means the plugin log factory was bound more than once in this classloader, usually because start() ran twice or another subsystem pre-bound the binder.","triggerScenarios":"ProfilerLoggingSystem.start() invoked twice on the same agent classloader; an earlier component (e.g. Log4j2LoggerBinderInitializer) already registered a binder for the same classloader.","commonSituations":"Agent restart logic calling start() again without stop(); tests initializing both the logging system and the binder initializer; multiple agent modules in one JVM sharing a classloader.","solutions":["Ensure start() is called only once per classloader lifecycle (guard with started flag)","Call stop()/unregister before re-initializing","Check whether Log4j2LoggerBinderInitializer.beforeClass() also ran in the same JVM and remove the duplicate path","Verify only one profiler logging component is on the classpath"],"exampleFix":"// before\nprofilerLoggingSystem.start();\nprofilerLoggingSystem.start(); // warns 'already initialized'\n// after\nif (!started) { profilerLoggingSystem.start(); started = true; }","handlingStrategy":"try-catch","validationCode":"// guard start(): boolean alreadyBound = com.navercorp.pinpoint.profiler.logging.PluginLogManager.bound(); if (alreadyBound) skip initialize;","typeGuard":null,"tryCatchPattern":"if (!PluginLogManager.initialize(binder)) { pluginLogger.warn(\"PluginLogManager already bound; skipping re-bind\"); }","preventionTips":["Call profilerLoggingSystem.start() once per lifecycle; guard with a started flag","Always stop()/unregister before restart","Avoid mixing Log4j2LoggerBinderInitializer and Log4j2LoggingSystem init in one classloader","Keep only one profiler-logging binder implementation on the classpath"],"tags":["logging","log4j2","initialization","classloader","lifecycle"],"backgroundTag":"double-initialization","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}