Quarkus access-log are not displayed - quarkus

I want access-log in my quarkus application and for this I followed Documentation.
The problem is, even i have enabled access-log with :
quarkus.http.access-log.enabled=true
No access log found in the console nor in any other file.
Is there any missing in my configuration ? Or should i use any other application server like undertow to be enabled ?
Quarkus version : 1.10.3.Final
Project based on quarkus-resteasy extension
content of application.properties
quarkus.log.level=WARN
quarkus.log.console.enable=true
quarkus.log.console.format=%d{HH:mm:ss} %-5p [%c{2.}] (%t) [%X{X-Request-Id}] [%X{X-Organization-Id}] %s%e%n
quarkus.log.console.level=DEBUG
quarkus.log.category."com.company".level=DEBUG
quarkus.http.access-log.enabled=true
quarkus.http.access-log.pattern=%h %l %u %t "%r" %s %b %m "%{i,Referer}" "%{i,User-Agent}" "%{i,X-Request-Id}" "%{i,X-Organization-Id}" %D
quarkus.http.access-log.base-file-name=project-name-log
quarkus.http.access-log.log-directory=/var/log/

The missing config was :
quarkus.log.category."io.quarkus.http.access-log".level=INFO
quarkus.http.access-log.log-to-file=true

Related

Spring Boot : LOGBack custom fields in every log statement

Thought of sharing the below work as I struggled to find this info:
Requirement is to put the business correlation id(AccCode and Mac) in every log statement. This can be done by using Mapped Diagnostic Context(MDC)..
No need to understand how LOGBack appender->Encoder->Layout work.
Spring boot log4j.properties has below pattern:
LOG_LEVEL_PATTERN=%5p
LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${PID} ${LOG_LEVEL_PATTERN} [%t] --- %c{1}: %m%n
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN}
Override LOG_LEVEL_PATTERN from application.properties with custom fields:
logging.pattern.level=AccCode:%X{AccCode} Mac:%X{Mac} %5p
Please note, now we have two extra fields defined into the layout. AccCode and Mac. Value for these new fields need to be provided using the MDC:
MDC.put("AccCode", "46014" );
MDC.put("Mac", "2025b9bcf");
Then all the log statements would have AccCode and Mac as below:
2016-09-12 09:11:37.574 **AccCode:46014** **Mac:2025b9bcf** DEBUG 9724 --- [main] c.c.p.sph.http.client.SphApAdminClient : Loging out from Sph

Hadoop log4j not working as No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory)

I am working on developing mapreduce using eclipse , and trying to test it using hadoop 2.6.0 windows standalone mode.
But getting the below error for log4j,
How to fix the below appender problem,
No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory)
same problem as hadoop log4j not working but no answer yet
Thanks ,
1- Create the file log4j.properties and put it in the location of
src/main/resources
the content of the log4j.properties
hadoop.root.logger=DEBUG, console
log4j.rootLogger = DEBUG, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n
it happens because of the hadoop logging framework
Create a log4j.properties file with something like the following:
hadoop.root.logger=DEBUG, console
log4j.rootLogger = DEBUG, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n

How to stop console logging for log4j in spring batch?

This is my log4j.properties file.
log4j.rootCategory=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
log4j.category.org.springframework.integration=FATAL
log4j.category.org.springframework.batch=FATAL
log4j.category.org.springframework.jdbc=FATAL
log4j.category.org.springframework.transaction=FATAL
I have tried changing the logging levels to INFO, ERROR etc. but nothing changes. I have this file in webapp/resources folder and i have added
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:/main/webapp/resources/log4j.properties</param-value>
</context-param>
to web.xml as well. But making changes to log4j.properties doesn't do anything. I can still see many DEBUG logs in console like this
17:06:06.405 [qtp2018468405-39] DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL query
How can I control logging level?
Logging level can be controled by using log4j.rootLogger property in log4j.properties file.
In your properties file I see you have not set log4j.rootLogger to INFO. Hence by default, the root logger is assigned to Level.DEBUG.

Why does this only log for hibernate?

Within my log4j.properties, log4j.rootLogger=DEBUG, stdout only shows debug data for hibernate. Can anyone explain this? I'm trying to debug other packages but none of them will work.
log4j.rootLogger=DEBUG, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c:%L - %m%n
I realized that you do NOT have log4j in your pom, you need these 3 dependencies to log with log4j and slf4j:
slf4j-api-x.x.x.jar
slf4j-log4j12-x.x.x.jar
log4j-x.x.x.jar
log4j and slf4j-log4j12 should have the same version.
Please also note the commet from #Stefan Lindenberg

log4j path in production for tomcat 7 on windows

I need simple path setting to use log4j to be used for logging FINEST level of logging. But all forums and discussions show path setting for log4j.properties file either under eclipse or in some dev env. For a non development user, i need to set log4j.properties file, i tried in C:\apache-tomcat-7.0.27\conf path, but dosent help. stdout logs show default logs, note I have deleted default ogging.properties from \conf folder.
Where do i put log4j.properties file in windows tomcat folder ?
well, as official docs say (http://tomcat.apache.org/tomcat-7.0-doc/logging.html), you should have not deleted, the default logging.properites file, present on:
${catalina.base}/conf/logging.properties
,but rather add there what you need:
org.apache.catalina.level=FINEST
and
You would need to ensure the ConsoleHandler's (or FileHandler's') level is also set to collect this threshold, so FINEST or ALL should be set.
Or is there any strict requirement for you to use log4j (as per default JULI is used by tomcat7)?
UPDATE:
OK, as you mentioned, you're interested in the log4j case only. Let me point you to the official documentation: http://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_Log4j
Please follow the steps present there. As they claim to be working :)
For the explicit points you mentioned, the location of the log4j.properties file:
Create a file called log4j.properties with the following content and save it into $CATALINA_BASE/lib
log4j.rootLogger=FINEST, CATALINA
# Define all the appenders
log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender
log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.
log4j.appender.CATALINA.Append=true
log4j.appender.CATALINA.Encoding=UTF-8
# Roll-over the log once per day
log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout
log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.LOCALHOST=org.apache.log4j.DailyRollingFileAppender
log4j.appender.LOCALHOST.File=${catalina.base}/logs/localhost.
log4j.appender.LOCALHOST.Append=true
log4j.appender.LOCALHOST.Encoding=UTF-8
log4j.appender.LOCALHOST.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.LOCALHOST.layout = org.apache.log4j.PatternLayout
log4j.appender.LOCALHOST.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.MANAGER=org.apache.log4j.DailyRollingFileAppender
log4j.appender.MANAGER.File=${catalina.base}/logs/manager.
log4j.appender.MANAGER.Append=true
log4j.appender.MANAGER.Encoding=UTF-8
log4j.appender.MANAGER.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.MANAGER.layout = org.apache.log4j.PatternLayout
log4j.appender.MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.HOST-MANAGER=org.apache.log4j.DailyRollingFileAppender
log4j.appender.HOST-MANAGER.File=${catalina.base}/logs/host-manager.
log4j.appender.HOST-MANAGER.Append=true
log4j.appender.HOST-MANAGER.Encoding=UTF-8
log4j.appender.HOST-MANAGER.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.HOST-MANAGER.layout = org.apache.log4j.PatternLayout
log4j.appender.HOST-MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Encoding=UTF-8
log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
# Configure which loggers log to which appenders
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=INFO, LOCALHOST
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager]=\
INFO, MANAGER
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager]=\
INFO, HOST-MANAGER
Compared to the official docs, I just changed the 1.st line of the config to: log4j.rootLogger=FINEST, CATALINA
(But make sure you do the rest of the steps as well - like copying of the jar files,...)

Resources