logging

How to use logging, pytest fixture and capsys?

心已入冬 提交于 2020-02-13 08:37:08
问题 I am trying to unit-test some algorithm that uses logging library. I have a fixture that creates a logger. In my 1st test case , I do not use this fixture and uses a print to log to stdout. This test case passes . In my 2nd test case , I use this fixture, but not as documented in pytest doc. I just call the associated function in my test to get the logger. Then I use the logger to log to stdout. This test case passes . In my 3rd test case , I use this fixture as documented in pytest doc. The

How to use logging, pytest fixture and capsys?

≯℡__Kan透↙ 提交于 2020-02-13 08:36:27
问题 I am trying to unit-test some algorithm that uses logging library. I have a fixture that creates a logger. In my 1st test case , I do not use this fixture and uses a print to log to stdout. This test case passes . In my 2nd test case , I use this fixture, but not as documented in pytest doc. I just call the associated function in my test to get the logger. Then I use the logger to log to stdout. This test case passes . In my 3rd test case , I use this fixture as documented in pytest doc. The

Logging output in Eclipse WTP server

隐身守侯 提交于 2020-02-13 05:01:07
问题 I'm running Eclipse 3.5 with Tomcat (integrated from WTP ) and I want to see the output logs in txt other than just the console Cant find it in my eclipse/workspace nor in the local Tomcat 6 installation directory Any clues how to enable these? I've also enabled org.apache.catalina.valves.RequestDumperValve and the output scrolls by on console which I want to see in txt 回答1: In the Servers tab: Double-click on the Tomcat Server. Click on "Open launch configuration". Click on the "Common" tab.

PHP: How to read a file live that is constantly being written to

戏子无情 提交于 2020-02-11 06:31:26
问题 I want to read a log file that is constantly being written to. It resides on the same server as the application. The catch is the file gets written to every few seconds, and I basically want to tail the file on the application in real-time. Is this possible? 回答1: You need to loop with sleep: $file='/home/user/youfile.txt'; $lastpos = 0; while (true) { usleep(300000); //0.3 s clearstatcache(false, $file); $len = filesize($file); if ($len < $lastpos) { //file deleted or reset $lastpos = $len; }

Log4J 2 not writing into file

偶尔善良 提交于 2020-02-08 04:14:25
问题 I am trying to implement some logging using log4j 2. The console output is ok, but when I try to write some logs into file I cannot manage it. My pom.xml : <dependencies> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.8</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.8</version> </dependency> </dependencies> My log4j2.xml : <?xml version="1.0" encoding="UTF-8

How can I disable logging from certain classes when using a common logger?

点点圈 提交于 2020-02-08 02:31:29
问题 I have created a common logger in the following manner in a root class that is referenced by many sub classes. public static final Logger LOGGER = Logger.getLogger(RootClass.class.getName()); Then I am accessing that logger in child classes in the following manner. private static final Logger LOGGER = RootClass.LOGGER; I have a main classes which receives inputs from users and it calls a method in the RootClass to configure the logger. logStatus = messageBus.configureLogPath(logPath,logLevel)

How to change testNG Reporter.log() encoding to UTF-16

本小妞迷上赌 提交于 2020-02-07 09:57:15
问题 I am using testNG with selenium. I have two kind of logger, one is log4j logger and the other is testNG Reporter.log() . Now the problem is I need to log some Chinese text. But it is coming as '????' instead of Chinese text. So I changed the log4j.properties file, just added two lines: log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.encoding=UTF-16 Now in my log4j logs it is coming properly but in testNG Reporter.log() it's still coming as '?????'. Log4j log:

How to change testNG Reporter.log() encoding to UTF-16

一世执手 提交于 2020-02-07 09:55:05
问题 I am using testNG with selenium. I have two kind of logger, one is log4j logger and the other is testNG Reporter.log() . Now the problem is I need to log some Chinese text. But it is coming as '????' instead of Chinese text. So I changed the log4j.properties file, just added two lines: log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.encoding=UTF-16 Now in my log4j logs it is coming properly but in testNG Reporter.log() it's still coming as '?????'. Log4j log:

How to configure JBoss JsonFormatter for Filebeat (WildFly 14)

心已入冬 提交于 2020-02-06 09:27:08
问题 I have Filebeat pulling logs from stdout. I want to ensure my logs are outputted as JSON, so they can be properly parsed. Thus far, here's what I've found: org.jboss.logmanager.formatters doesn't have a JSON formatter There's an "extension" module that provides a JsonFormatter class. I can use it in my logging.properties by doing something like this: handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler handler.CONSOLE.properties=autoFlush,target handler.CONSOLE.autoFlush=true handler

Java: Is this proper behavior of singleton class used to save basic JDK log file?

白昼怎懂夜的黑 提交于 2020-02-06 07:41:45
问题 I created the below wrapper for a singleton logger class so that I can log exceptions from any file and/or class. My inspiration comes from here: Logging to one file from multiple java files I'm new to java and this is my first use of attempting to log exceptions to a file. While the following code does work, I noticed a few quirks I wanted to ask whether or not they were "normal behavior" or whether a workaround exists. (1) Once the log file is created and has been written to with exceptions