log4j

log4j log file in user home directory

一个人想着一个人 提交于 2020-01-01 02:43:24
问题 I am working on an application that will run on OSX and windows. I want the logs to be written to the users home directory. For OSX it will be under the /Users//Library/Application Support/MyApp/log directory, and under windows depending on the version under /Users//AppData/MyApp/log directory. What is the best way I can do this? I have looked around for solutions for this, but nothing helpful or a solution I am comfortable using has come up. Look forward to your inputs. edit: Since the

How to show log4j output in surefire test resports

房东的猫 提交于 2020-01-01 01:53:13
问题 When a test fails in maven the surefire test report xml files in target/surefire-reports/TEST-<test-name>.xml only shows the Standard Output System.output or Standard Error System.err When I use the jdk java.util.logging.Logger all the logging shows in the Standard Error <system-err> tag , but it does not show when I use log4j. The logging with log4j is working fine through a FileAppender and a ConsoleAppender. It shows in the full console output, but not on the individual test report files.

Use system properties OR variables in log4j

纵饮孤独 提交于 2019-12-31 21:43:52
问题 I want to to do like this: <appender name="ErrorLog" class="org.apache.log4j.FileAppender"> <param name="File" value="${error.log.path}"/> <param name="Append" value="true" /> <param name="Threshold" value="ERROR"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%C{1} %L [%t] %d{dd MMM,yyyy HH:mm:ss.SSS} %-5p - %m%n" /> </layout> </appender> Notice this line: <param name="File" value="${error.log.path}"/> I tried to set the values like this: public

打印的日志哪里去了?

不羁岁月 提交于 2019-12-31 18:00:14
1.1 两个工程: umf-pay-sdk |---umf-pay-sdk-core |--umf-pay-demo 其中, 这个工程用来对接联动的支付接口,依赖log4j来打印日志。umf-pay-sdk-core是一个module,编译后会打成jar。umf-pay-demo是测试主程序,用来测试ymf-pay-sdk-core的api。 draft_server 是一个应用,使用的日志框架是log4j2。它依赖很多jar,其中就包括umf-pay-sdk-core。 1.2 umf-pay-sdk-core记日志的方式是用log4j。并定义了log4j.properties。 import org.apache.log4j.LogManager;import org.apache.log4j.Logger; private static final Logger log = LogManager.getLogger("UMF"); ######################################################## # for Log4j/Logger4 ######################################################## log4j.rootCategory=INFO, stdout,UMF log4j

Does log4j support JSON format?

你离开我真会死。 提交于 2019-12-31 10:31:49
问题 Is it possible to let log4j output its logging in JSON format by only altering the log4j.properties.xml configuration file? I make use of an old application that uses log4j 1.2 . I only see the XML layout but no JSON layout. 回答1: just use buildin PatternLayout is ok: log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.encoding=UTF-8 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern={"debug_level":"%p","debug

activiti 基础搭建

血红的双手。 提交于 2019-12-31 03:52:22
首先在eclipse内添加activiti的插件,https://blog.csdn.net/qq_22701869/article/details/79537971 1.创建一个maven的java工程 2.在pom文件内导入下面的包 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.xfma</groupId> <artifactId>acticvity</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.7</maven.compiler.source> <maven

聊一聊log4j2配置文件log4j2.xml

狂风中的少年 提交于 2019-12-31 02:35:57
一、背景   最近由于项目的需要,我们把log4j 1.x的版本全部迁移成log4j 2.x 的版本,那随之而来的slf4j整合log4j的配置( 使用Slf4j集成Log4j2构建项目日志系统的完美解决方案 )以及log4j2配置文件的详解,就需要我们来好好聊一聊了。本文就专门来讲解下log4j2.xml配置文件的各项标签的意义。 二、配置全解   1.关于配置文件的名称以及在项目中的存放位置     log4j 2.x版本不再支持像1.x中的.properties后缀的文件配置方式,2.x版本配置文件后缀名只能为".xml",".json"或者".jsn".     系统选择配置文件的优先级(从先到后)如下:       (1).classpath下的名为log4j2-test.json 或者log4j2-test.jsn的文件.       (2).classpath下的名为log4j2-test.xml的文件.       (3).classpath下名为log4j2.json 或者log4j2.jsn的文件.       (4).classpath下名为log4j2.xml的文件.      我们一般默认使用log4j2.xml进行命名。如果本地要测试,可以把log4j2-test.xml放到classpath,而正式环境使用log4j2.xml

基础服务系列-Docker 安装MongoDB

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-30 16:08:21
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> MongoDB is a free and open-source cross-platform document-oriented database program. 下载镜像 docker pull mongo 启动 docker run --name test-mongo -p 27017:27017 -d mongo:latest 下载web管理界面镜像 docker pull mongo-express 关联Mongo容器 docker run --link test-mongo:mongo -p 8082:8081 mongo-express Web访问 浏览器访问web管理界面, http://192.168.119.254:8082/ 应用程序访问 依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.8.RELEASE</version> </parent> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring

Log4j2 not working with json config file

孤街浪徒 提交于 2019-12-30 14:17:27
问题 It seems like log4j is trying to parse .json config file by XML parser, but why? I set log4j config file by command line argument: -Dlog4j.configurationFile=src/log4j2.json file content: { "configuration": { "appenders": { "Console": { "name": "Console", "target": "SYSTEM_OUT", "PatternLayout": { "pattern": "%date %thread %logger %message" } } }, "loggers": { "root": { "level": "debug", "appender-ref": { "ref": "Console" } } } } } What I get: [Fatal Error] log4j2.json:1:1: Content is not

Java日志介绍(2)-Log4j

末鹿安然 提交于 2019-12-30 14:13:06
  Log4j是Apache的一个开源项目,官网地址为http://logging.apache.org/log4j/1.2/index.html。通过使用Log4j,可控制日志信息输出到控制台、文件、数据库等不同的地方;可以控制每一条日志的输出格式,通过定义每一条日志信息的级别,可以更加细致的控制日志的生成过程。Log4j是曾经风靡一时的日志框架,但现在逐渐被新的日志框架所取代:Log4j2、logback。本文主要介绍下Log4j的使用方法,文中所使用到的软件版本:Java 1.8.0_191、log4j 1.2.17。   Log4j由三个重要的组件构成:日志信息的优先级,日志信息的输出目的地,日志信息的输出格式;下面将逐一介绍。 1、日志信息的优先级 Log4j日志级别是定义在org.apache.log4j.Level类中,Log4j只建议使用其中4个级别,优先级从高到低分别是error、warn、info、debug。 2、日志信息的输出目的地 (appender) Log4j提供的appender有以下几种: org.apache.log4j.ConsoleAppender(控制台) org.apache.log4j.FileAppender(文件) org.apache.log4j.DailyRollingFileAppender(每天产生一个日志文件) org