All Questions
Tagged with log4j2 spring-boot
505 questions
0
votes
1
answer
38
views
Springboot with logback working, with log4j2 working, but not working when using both
I am observing an issue when sending logs to both log4j2 and logback using kafka.
Here is the code of my very simple Springboot app:
@SpringBootApplication
public class QuestionApplication {
...
1
vote
1
answer
76
views
experiensing "Protocol vfs has not been enabled as an allowed protocol" error while deploying the Spring boot WS to JBoss EAP 8
I am working on developing a spring boot(3.3.5) web service with log4j2 as my logging library. I generated a spring boot project from spring initializer, excluded the logging from web module to ...
0
votes
0
answers
20
views
How do you log a message if your Event Template expects a map but doesn't receive a map in log4j2?
I want to be able to use Log4j2 to log in JSON format. I am using JsonTemplateLayout and my own Event Template. My application uses MapMessage when logging so I can extract out values for my log ...
1
vote
1
answer
83
views
Dynamically set DEBUG or INFO logging level per request based on request header in reactive Spring Boot with Log4j2
I'm working on a Reactive Spring Boot application that uses Log4j2 as the logging framework. By default, my application logs at the INFO level, and I set the logging level in the application.yml
I ...
0
votes
0
answers
47
views
Tracing kafka message event in lmax disruptor ring buffer sequence
Below is the code for kafka message consumed and published within lmax disruptor ring buffer, now i need to implement tracing for each event may goes through multiple sequence. Before publishing the ...
1
vote
2
answers
45
views
log4j2 syslog appender not working in springboot
I'm trying to use log4j2 syslog appender to write messages to syslog from my springboot application.
Here is my log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ...
0
votes
1
answer
61
views
No factory method found for class HttpAppender
I was trying to use log4j2 HttpAppender, but I get this error:
2024-09-24T07:59:58.504101611Z main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.HttpAppender for ...
0
votes
0
answers
80
views
Log didin't write into filename that specified in log4j2-spring.xml file
Spring boot version 3.3.3, in my linux system I will have two tomcat instance under /opt, one is called /opt/tomcat (which is the dev environment, specified in conf/catalina.properties with spring....
0
votes
0
answers
38
views
How to Prevent Duplicate Logs in Log4j2 Configuration?
I’m working with a Log4j2 XML configuration and I’ve encountered an issue where duplicate logs are being written to the log files. I’m trying to prevent this duplication but am unsure of how to adjust ...
1
vote
1
answer
39
views
pb Logging in db with spring boot 3 and log4j2
I try to save in my db the logs of the console for querying easily on it. It's almost working. Log is ok but I have error log before the end of the spring boot context initialisation. After it's ok.
...
0
votes
0
answers
18
views
How to wirte two log using Log4j2 in the same time?
I have an issue when try to logs multiple time logs in the application
I have two file
-log4j2.xml is default log, log anything hit my application
-log4j2-by-user.xml it almost the same configure ...
2
votes
1
answer
158
views
How can I unit test whether my app logs as expected with log4j2?
I tried using reflection, but in my case sl4fj creates a final logger. This means I can't customize it.
Any advice?
0
votes
1
answer
207
views
HTTP trace logging when using Spring Cloud Gateway in a SpringBoot fat JAR
We recently converted a Spring Boot application from a WAR running on Tomcat to a Spring Fat JAR. I would like the ability to record when an incoming HTTP request is recevied and when the response is ...
1
vote
1
answer
349
views
How to allow object deserialization in Java JDK 21?
I am working on a vulnerable web application which I am integrating with Spring Boot to demonstrate Log4J vulnerability. My vulnerable web application works with my exploit on JDK 1.8. However, the ...
0
votes
0
answers
67
views
Log4J2.xml file is not generating a log file
I'm having an issue with my Log4J2.xml file. It is placed in the resources folder. It seems that my log4j2.xml file is literally being ignored by Springboot. Attached is the XML configurations.
<...
1
vote
1
answer
267
views
Multi Pod Cloud Environment Spring Boot application change log level at runtime
I have an application used spring boot + log4j2 running on openshift more than 2 pods.
However, our logging configuration changing after sprint boot initalized i mean , reconfigure. So, i do not use ...
0
votes
0
answers
116
views
How to do I make child gradle project inherit dependencies and exclusions from parent project?
I am trying to create a project with Gradle and Spring Boot, which will have dependencies and exclusions that should be inherited by any child project that implements it.
I am using a Kotlin DSL build....
0
votes
1
answer
197
views
How to print log4j2 json attributes only if it's value is present in ThreadContext using JsonLayoutTemplate
I want to log 2 custom fields in log4j2 Json Format, out of which one is having fixed value, and other one is derived from ThreadContext. I'm using JsonTemplateLayout and want to print the field only ...
-1
votes
1
answer
1k
views
Correlation ID missing in logs after enabling Log4j2 with Micrometer setup in Spring Boot 3.2.0
I recently implemented Micrometer setup in my Spring Boot 3.2.0 application to enhance tracing and metrics collection, which worked fine. However, after enabling Log4j2 for improved logging, I noticed ...
0
votes
0
answers
57
views
Logs file getting created but logs are not getting written to it in springboot 3 war deployed on Tomcat 10.1.19
log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Properties>
<Property name="LOG_PATTERN">...
0
votes
1
answer
69
views
Log4j is not writing logs into file
Thanks in Advance, I am trying to write logs into a file using log4j, I have tried all log4j.properties but nothing worked. Below is the code.
import org.apache.logging.log4j.LogManager;
...
0
votes
0
answers
66
views
Dynamic Log path value in the Log4j2.properties
Facing issue while substituting the dynamic log path value in the external log4j2.properties in the Spring boot application during startup
here the log4j2.properties whhich is kept outside of the ...
1
vote
1
answer
339
views
Spring Boot 3.2 automatically change log level during shutdown
We recently upgraded springBoot version to 3.2, and Java 21 64 bit.
We observed wired behaviour while shutting down spring boot application , log level automatically change INFO to ERROR, and we are ...
0
votes
2
answers
493
views
Log4j2 CLASS_NOT_FOUND Error for Layout Element in Spring Boot Project
I recently migrated to Log4j2 in my Spring Boot project and encountered an error related to the layout configuration in my log4j2.xml. Despite following the recommended configuration steps, I'm still ...
1
vote
1
answer
808
views
SpringBootApplication with log4j2 throws error on start
I configured my log4j2.yml with properties from springboot:
Properties:
property:
- name: LOGSTASH_HOST
value: ${spring:logstash.server.host}
- name: LOGSTASH_PORT
...
1
vote
1
answer
146
views
Intermittent Syslog Messages Missing with Log4j2
I am currently working on a project where I have to manage logging using Log4j2. I am facing a specific issue related to updating log levels in the log4j2.xml file via a PUT API call.
While the API ...
0
votes
1
answer
84
views
log4j2 works on Mac but not on Windows
I have log4j2 working in Springboot working fine on the Mac. The log4j.properties file is in the /src/main/resources folder.
On the mac, logs work fine. Yet, on Windows, the same SpringBoot Tomcat ...
1
vote
1
answer
175
views
how to centralize log4j2 configuration with Spring Cloud Config Server
I'm using Spring Cloud Config Server File System Backend : docs.spring.io
I have a multi maven project
project:
├── pom.xml
│
├── project-config-provider
│ ├── pom.xml
│ ├── src
│ │ └── main
│ ...
2
votes
1
answer
178
views
how to reference other properties into log4j2 yaml configuration?
I'm using the following log4j2.yaml configuration:
Configuration:
Appenders:
Console:
name: Console
target: SYSTEM_OUT
JSONLayout:
compact: true
eventEol: true
...
0
votes
0
answers
66
views
All Logs not getting printed in console or File
So I am using Log4j2 with SLF4j for Logging in Spring Boot application. I have console and File logging enabled.
Only logs related to spring boot are getting printed on the file and console. None of ...
0
votes
2
answers
2k
views
Micrometer traceId and spanId are missing with log4j2
after I migrated my app from spring boot 2.7 to 3.1.5, I am not able to log traceId and spanId to the logger.
I migrated sleuth to micromerter, as described in migration guide and edited the log4j2....
0
votes
0
answers
50
views
How to exclude unpacked dependencies from third-party jars?
I have a spring boot application MyApp. MyApp is having a dependency on a third-party library ThirdParty which is also a spring-boot application. This ThirdParty library is a fat jar where all the ...
0
votes
2
answers
127
views
log4j2.xml is not recognised by Spring Boot
I am trying to create logs using the log4j-core Maven dependency in Spring Boot. When I try to use below code in application.properties, error logs are generated
application.properties :
# Set the ...
1
vote
1
answer
3k
views
ERROR FOUND : No SLF4J providers were found. and Defaulting to no-operation (NOP) logger implementation
My log file is not generated I am getting above error while start my spring boot application. please help me to resolve .
<parent>
<groupId>org.springframework.boot</groupId&...
3
votes
2
answers
1k
views
how to add an extra string or key/value pair only for some specific log message in java spring boot project
In my spring boot application, we need to add an extra tag( key/value pair) only for some specific log messages to highlight that these are some special purpose logs and not for others.
Project log4j2....
1
vote
2
answers
354
views
Why does log4j filter not works inside appender
I've create a custom filter that looks like this:
@Plugin(name = "EmptyMessageFilter", category = Node.CATEGORY, elementType = Filter.ELEMENT_TYPE, printObject = true)
public class ...
0
votes
1
answer
278
views
How to inherit log4j2.xml from parent project to child?
This is my first use of log4j and I don't find any documentation regarding my problem.
I have a SpringBoot (2, and java 8) parent project with a log4j2.xml file inside it.
The file is like this:
<?...
0
votes
1
answer
856
views
Hibernate debug/trace logging when both logback and log4j are in classpath
Having:
Spring-boot:2.6.7
Hibernate:5.6.8
logback as default logging implementation
Apache POI poi-ooxml:5.2.3.
We need to log SQL queries and parameters. Usually this is enabled either from Spring ...
0
votes
1
answer
671
views
Error when changing the log file for appending logs in a Spring Boot application
I face this error when I change the file where I write logs
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
...
0
votes
2
answers
982
views
Problem with log4j2 to write all logs to a specific file in Spring Boot 3.1.0 with Maven
I am trying to set log4j2 to write all logs to a specific file. I've tried various things I found on the internet but still the logs only show up in the console.
I am using IntelliJ IDEA CE.
Spring ...
0
votes
2
answers
1k
views
approach to upgrade my log4j1.2.17 used inside springboot-starter-parent 1.5.6
Log4j1.2.17 included inside my code is not used directly, rather it is being called from another JAR file – log4j-over-slf4j1.7.25 and this Jar is being used from the spring-boot-starter-1.5.6....
6
votes
1
answer
2k
views
Native compile spring boot 3 with log4j2 java.lang.NoSuchMethodException: org.apache.logging.log4j.message.DefaultFlowMessageFactory.<init>()
When I compile a spring boot 3 application to native image using the plugin, e.g:
./gradlew bootBuildImage --imageName=example.com/library/my-app:v1
and then run it:
docker run --rm -p 5050:5050 ...
0
votes
1
answer
347
views
Log4j2 Error appears as Fatal message when following a tutorial
I am trying to follow the below tutorial to add Log4j2 logging to my Spring application. https://www.dataset.com/blog/maven-log4j2-project/
When testing out Log4j2 in application, the FATAL level log ...
3
votes
1
answer
766
views
Script support is not enabled - Spring boot 2.7.5
We are using Log4j2 with a script in the configuration (log4j2.xml) of the appenders to use with graylog.
<Appenders>
<ScriptAppenderSelector name="SelectGelf">
<...
0
votes
1
answer
81
views
Set KeyValuePair in KafkaAppender
Here i want to set key value pair. all other features are working.
i want to use log4j2.properties file.
appender.kafka=org.apache.kafka
appender.kafka.type= kafka
appender.kafka.name= kafkaAppender
...
0
votes
0
answers
26
views
Read log file entries based on logged in user name
I have a log file like below
2023-06-13 09:48:07,060 [127.0.0.1 APP-NAME#USER_A] org.hibernate.SQL.logStatement(SqlStatementLogger.java:94) Thread=default task-10
- DEBUG -
select
...
0
votes
1
answer
1k
views
After connecting Log4j2 spring boot application throws java.lang.NoClassDefFoundError
I am new to programming. I have a multi-module application. After I excluded spring-boot-starter-logging in POM.xml and connecting Log4j2, Spring Boot application throws an exception java.lang....
1
vote
1
answer
537
views
Log4j2 JDBC Appender PoolingDriver configuration
I'm trying to configure Log4j2 using JDBC Appender with the following log4j2.xml file for my Spring Boot application:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration&...
0
votes
1
answer
225
views
logging.config in application.properties gets not picked up
currently, I am working on a Spring Boot application that I bundle and deploy as a war to a Tomcat Servlet Container.
I want to configure log4j2. When I include a file named log4j2.xml the ...
0
votes
0
answers
41
views
Log4j appender logs more levels than expected
I have the following log4j2.xml file for my Spring Boot project:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name=&...