nodece opened a new pull request, #22017:
URL: https://github.com/apache/pulsar/pull/22017

   ### Motivation
   
   I switched the log level from info to debug by `log4j2.yaml` file, but there 
is no debug log for pulsar in the console.
   
   The following is the log4j2 debug log(`LOG4J_DEBUG=true bin/pulsar 
standalone -nfw`):
   ```
   DEBUG StatusLogger Watching configuration 
'/Users/zixuan/repo/pulsar/conf/log4j2.yaml' for lastModified Sat Feb 03 
18:07:39 CST 2024 (1706954859387)
   DEBUG StatusLogger Apache Log4j Core 2.18.0 initializing configuration 
YamlConfiguration[location=/Users/zixuan/repo/pulsar/conf/log4j2.yaml]
   ...
   DEBUG StatusLogger Completed parsing configuration
   DEBUG StatusLogger Building Plugin[name=property, 
class=org.apache.logging.log4j.core.config.Property].
   DEBUG StatusLogger createProperty(name="pulsar.log.dir", value="logs", 
Configuration(pulsar))
   DEBUG StatusLogger Building Plugin[name=property, 
class=org.apache.logging.log4j.core.config.Property].
   DEBUG StatusLogger createProperty(name="pulsar.log.file", 
value="pulsar.log", Configuration(pulsar))
   DEBUG StatusLogger Building Plugin[name=property, 
class=org.apache.logging.log4j.core.config.Property].
   DEBUG StatusLogger createProperty(name="pulsar.log.immediateFlush", 
value="false", Configuration(pulsar))
   DEBUG StatusLogger Building Plugin[name=property, 
class=org.apache.logging.log4j.core.config.Property].
   DEBUG StatusLogger createProperty(name="pulsar.log.appender", 
value="RoutingAppender", Configuration(pulsar))
   DEBUG StatusLogger Building Plugin[name=property, 
class=org.apache.logging.log4j.core.config.Property].
   DEBUG StatusLogger createProperty(name="pulsar.log.root.level", 
value="debug", Configuration(pulsar))
   DEBUG StatusLogger Building Plugin[name=property, 
class=org.apache.logging.log4j.core.config.Property].
   DEBUG StatusLogger createProperty(name="pulsar.log.level", value="debug", 
Configuration(pulsar))
   DEBUG StatusLogger Building Plugin[name=property, 
class=org.apache.logging.log4j.core.config.Property].
   DEBUG StatusLogger createProperty(name="pulsar.routing.appender.default", 
value="Console", Configuration(pulsar))
   DEBUG StatusLogger Building Plugin[name=properties, 
class=org.apache.logging.log4j.core.config.PropertiesPlugin].
   DEBUG StatusLogger configureSubstitutor(={pulsar.log.dir=logs, 
pulsar.log.file=pulsar.log, pulsar.log.immediateFlush=false, 
pulsar.log.appender=RoutingAppender, pulsar.log.root.level=debug, 
pulsar.log.level=debug, pulsar.routing.appender.default=Console}, 
Configuration(pulsar))
   ...
   DEBUG StatusLogger Building Plugin[name=AppenderRef, 
class=org.apache.logging.log4j.core.config.AppenderRef].
   DEBUG StatusLogger createAppenderRef(ref="RoutingAppender", level="INFO", 
Filter=null)
   ...
   DEBUG StatusLogger Started configuration 
YamlConfiguration[location=/Users/zixuan/repo/pulsar/conf/log4j2.yaml] OK.
   ```
   
   You can see the `RoutingAppender` uses the `INFO` level in the above log.
   
   In the `bin/pulsar`, we use the system properties to set the log4j2 log 
level, and it looks higher priority than the `log4j2.yaml` file. 
   
   When I remove the `PULSAR_LOG_LEVEL` and `PULSAR_LOG_ROOT_LEVEL` variables 
in the `bin/pulsar`, and then change the log level from info to debug in the 
`log4j2.yaml` file, it works fine.
   
   ### Modifications
   
   When the `PULSAR_LOG_LEVEL` or `PULSAR_LOG_ROOT_LEVEL` is set by the user, 
we set the log level by system properties. 
   
   **Note:** This way doesn't support changing the log level by the 
`log4j2.yaml`.
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to