Comments (9)
Can you add the contents of your log4j.properties
file to your question? Since version 2.17.0, log4j-1.2-api
has changed a lot. For example the builder for org.apache.log4j.RollingFileAppender
configured a time-based rotation instead of a size-based one (cf. #710).
from logging-log4j2.
Sure, there you go
# Encoding: UTF-8
log4j.logger.com.Common.model.Log4jAP=ALL, AP_Log
log4j.appender.AP_Log=org.apache.log4j.DailyRollingFileAppender
log4j.appender.AP_Log.File=D:/Handler_AP/log/AP/AP_Log.log
log4j.appender.AP_Log.DatePattern='.'yyyy-MM-dd
log4j.appender.AP_Log.Append=true
log4j.appender.AP_Log.encoding=UTF-8
log4j.appender.AP_Log.layout=org.apache.log4j.PatternLayout
log4j.appender.AP_Log.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %m%n
from logging-log4j2.
@ppkarwasz
Hi, may I ask if you see anything wrong about the DailyRollingFileAppender
? or my settings?
from logging-log4j2.
Your configuration works correctly, but the logger name "com.Common.model.Log4jAP" seems suspicious (if Common
is a package name, it should be lowercase common
).
from logging-log4j2.
"com.Common.model.Log4jAP" seems suspicious
Yes, it's package name. Somehow the top guys made rules to name like this long time ago.
Hmmm, so my config should be working properly but it isn't... I have enabled log4j's root logger, and it printed this line in log
log4j:ERROR Failed to rename [D:/Handler_AP/log/AP/AP_Log.log] to [D:/Handler_AP/log/AP/AP_Log.log.2023-02-11]
Is this a bug like this?
https://bz.apache.org/bugzilla/show_bug.cgi?id=29726
from logging-log4j2.
Messages prefixed by log4j:
were used by the unsupported Log4j 1.2. Make sure that:
- You don't have
log4j:log4j
on your classpath, - You have
org.apache.logging:log4j-1.2-api
on your classpath, - Either the system property
log4j1.compatibility=true
is set orlog4j.configuration
points to yourlog4j.properties
file.
from logging-log4j2.
Messages prefixed by
log4j:
were used by the unsupported Log4j 1.2. Make sure that:* You **don't** have [`log4j:log4j`](https://mvnrepository.com/artifact/log4j/log4j) on your classpath,
I have checked its lib folder, POM, and IDE build path, no old Log4j 1.2 included.
* You have [`org.apache.logging:log4j-1.2-api`](https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-1.2-api) on your classpath,
log4j-1.2-api-2.19.0.jar, log4j-api-2.19.0.jar, log4j-core-2.19.0.jar. just them.
* Either the system property `log4j1.compatibility=true` is set or `log4j.configuration` points to your `log4j.properties` file.
doesn't have any system prop setting inside my program, but I do have a simple mechanism to read my properties file.
public class Log4j {
public final static Logger LOG = Logger.getLogger(Log4j.class);
private static boolean configurated = false;
public Log4j() {
};
public Log4j(String config_path) {
if (configurated == false) {
Properties p = new Properties();
try {
p.load(new FileInputStream(config_path));
PropertyConfigurator.configure(p);
configurated = true;
} catch (IOException e) {
System.out.println("[Error] Unable to read log4j config: " + e.getMessage());
} finally {
if (p != null) {
p.clear();
}
}
}
};
}
This works fine since 1.12.x to 2.17.0 over the past few years. I still cannot understand why it won't on 2.19.0.
from logging-log4j2.
PropertyConfigurator#configure()
was a no-op before version 2.17.2 (cf. source code). Another mechanism must be configuring your logging system.
from logging-log4j2.
I am closing this since it can not be reproduced and it probably concerns Log4j 1.x/Reload4j.
Feel free to reopen it if there is new data.
from logging-log4j2.
Related Issues (20)
- Revamp the `Configuration` page HOT 2
- Revamp the `Lookups` page
- Revamp the `Layouts` page
- Revamp the `Appenders` page HOT 1
- Revamp the `Filters` page
- Revamp the `Extending` page
- Revamp the `Plugins` page
- Create a `Troubleshooting` page
- Revamp the `Performance` page
- Revamp the `Asynchronous logging` page
- Revamp the `API` page
- Uniform handling of location and URIs HOT 1
- [MS14] Documentation revamp 1/5
- [MS15] Documentation revamp 2/5
- [MS16] Documentation revamp 3/5
- [MS17] Documentation revamp 4/5
- [MS18] Documentation revamp 5/5
- Revamp the `Web Applications` page
- Implement uniform password "encryption/decryption" mechanism HOT 2
- When logging from multiple threads, an appender can be broken until app restart if it rolls over HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logging-log4j2.