logging

why is log4 appender member is null? cannot init log4j

◇◆丶佛笑我妖孽 提交于 2020-01-06 23:49:08
问题 I have this log4j.properties file # Root logger log4j.rootLogger=INFO, sift log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer log4j.configDebug = true # Sift appender log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender log4j.appender.sift.key=session_id log4j.appender.sift.default=no_session_id log4j.appender.sift.appender=org.apache.log4j.FileAppender log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout log4j.appender.sift.appender.layout.ConversionPattern

Log4j.xml injecting Evaluator

可紊 提交于 2020-01-06 21:21:48
问题 My project is using log4j 1.2.17. I have successfully injected my custom "Evaluator" into the SMTPAppender, using setEvaluatorClass : <appender name="email" class="org.apache.log4j.net.SMTPAppender"> <param name="EvaluatorClass" value="path.to.my.Evaluator" /> However, I would like to pass some params to my Evaluator, to make it configurable. I would like to use SMTPAppender.setEvaluator, but I cannot figure out how to set that up in log4j.xml. Another option would be the other SMTPAppender

Where check log why VM doesn't running for jconsole with custom jar?

三世轮回 提交于 2020-01-06 19:38:59
问题 I try run jconsole with jar that contains my classes like: cd "C:\Program Files\Java\jdk1.6.0_26\bin" set console="C:\Program Files\Java\jdk1.6.0_26\lib\jconsole.jar" set tools="C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar" set customjar="C:\custom.jar" jconsole -J-Djava.class.path=%console%:%tools%:%customjar% But nothing happens - jconsole doesn't start! Where to check what error happens? BTW simple jconsole - startds, all paths are checked and correct. Thanks. 回答1: As I remember you

how to temporarily make a field thread local

天涯浪子 提交于 2020-01-06 16:33:56
问题 My class is like this, basically I'm writing a servlet, and I want to change the log level for a specific user connected to my servlet and leave other log settings for other user unchanged, since the server will produce one thread to serve one client, I'm writing demo code use only threads public Class A implements Runnable { Logger myLogger = new Logger(); @Override public void run() { if (Thread.currentThread.getName()).equals("something") { // some code that makes myLogger thread-local so

Python using logger with multiple handlers

≡放荡痞女 提交于 2020-01-06 15:49:50
问题 If I define a logger with 2 handlers in a module A # module A import logging logger = logging.getLogger('PARSER') logger.setLevel(logging.DEBUG) # create file handler which logs even debug messages fh = logging.FileHandler('glm_parser.log') fh.setLevel(logging.DEBUG) # create console handler with a higher log level ch = logging.StreamHandler() ch.setLevel(logging.INFO) # create formatter and add it to the handlers formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %

Django 1.4 “LOGGING” variable in settings.py seems to be ignored

折月煮酒 提交于 2020-01-06 15:41:31
问题 I've got a module I want to log in Django that looks something like this: import logging logger = logging.getLogger(__name__) def foo(): #this is a test of logging logger.info("info foo") logger.warning("warn foo") logger.error("error foo") My LOGGING in settings.py is set to the following: LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'simple': { 'format': '%

.Net Core 3: Serilog don't log custom logs

≡放荡痞女 提交于 2020-01-06 15:22:05
问题 I have a web .NET Core 3 application using Serilog. If I filter the technical logs from MS namespaces, all logs disapear, event custom one. What I did I configure Serilog in Main.cs like this: public static int Main(string[] args) { var currentEnv = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($

logstash-elasticsearch: sort data by timestamp

ぃ、小莉子 提交于 2020-01-06 15:00:11
问题 I centralize logfiles into one logfile by using logstash and for each event I have timestamp(the original one). Now, my last challenge it to get this data sorted by timestamp(if possible on real-time thats better). my timestamp format is: yyyy-MM-dd HH:mm:ss Now, I can make any change in the format/ file format in order to make it work, as long as it stays on our servers. What's the best way to sort my data? any ideas? Thanks in advance! 来源: https://stackoverflow.com/questions/30188847

JavaLogger randomly writes to a second file

六月ゝ 毕业季﹏ 提交于 2020-01-06 12:43:48
问题 I have a jar that is called about every minute from another script. In this jar I have created a JavaLogger that logs what happens while the Jar runs. The log file that JavaLogger writes to is called myLog.0. I have the following code to allow it to go to .1/.2/.3/.4. try { FileHandler fileHandler = new FileHandler(filePath, 5242880, 5, true); fileHandler.setFormatter(new java.util.logging.Formatter() { @Override public String format(LogRecord logRecord) { return "[" + logRecord.getLevel() +

Python can you accidentally overwrite a logger by using getLogger with the same name?

半城伤御伤魂 提交于 2020-01-06 12:21:11
问题 In my Python program, I import a module (let's say it's called bananas ). The module gets a logger inside its __init__.py by doing this: _logger = logging.getLogger(__name__) . Thus, the logger's name is bananas . In my program (the one that imports the module bananas ), I also have this line: my_logger = logging.getLogger("bananas") . Does this: Overwrite _logger made in bananas ? Fetch that logger, and thus my_logger now equals _logger ? Something else entirely Thank you for your help! 回答1: