log4j2

Log4j2: SMTPAppender does not send mails with error or fatal level

早过忘川 提交于 2019-12-01 04:37:40
I recognized some problems with the SMTPAppender in log4j2. Whenever log events with the level error or fatal are created without having an event with the level info before no mail is sent and the fatal event disappears. Here is my log4j2 configuration file (log4j2.xml) and a small program (LogTest.java) to reproduce the problem: <?xml version="1.0" encoding="UTF-8"?> <configuration status="warn"> <!-- mail server configuration --> <properties> <property name="receipients">me@example.com</property> <property name="from">me@example.com</property> <property name="smtpHost">smtp.example.com<

Logging using Log4J2 on aws lambda - Class not found

99封情书 提交于 2019-12-01 04:29:37
问题 I am trying to use Log4J2 logging as described here in the AWS docs: https://docs.aws.amazon.com/lambda/latest/dg/java-logging.html#java-wt-logging-using-log4j2.8 <?xml version="1.0" encoding="UTF-8"?> <Configuration packages="com.amazonaws.services.lambda.runtime.log4j2.LambdaAppender"> <Appenders> <Lambda name="Lambda"> <PatternLayout> <pattern>%d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1}:%L - %m%n</pattern> </PatternLayout> </Lambda> </Appenders> <Loggers> <Root level="debug">

How to delete older rolled over log4j2 logs, keeping up to 10 files?

风流意气都作罢 提交于 2019-12-01 03:56:53
What I want is: Maximum of 10 log files, in total Each log file, not more than 50MB in size. Thus the logs folder never grows over (50MB *10 )= 500MB. But it seems my log4j2 config is not properly done. What is happening is: Logs do roll over after 50 MB But there are upto 10 logs kept per day Thus there is no limit of number of log files kept in log folder (since for eg, in 2 days, 20 logs of 50mb each have collected) Here is the config: <Configuration status="WARN"> <Appenders> <RollingFile name="RollingFile" fileName="log/my.log" filePattern="log/my-%d{MM-dd-yyyy}-%i.log"> <PatternLayout>

Log4j2: SMTPAppender does not send mails with error or fatal level

核能气质少年 提交于 2019-12-01 03:16:08
问题 I recognized some problems with the SMTPAppender in log4j2. Whenever log events with the level error or fatal are created without having an event with the level info before no mail is sent and the fatal event disappears. Here is my log4j2 configuration file (log4j2.xml) and a small program (LogTest.java) to reproduce the problem: <?xml version="1.0" encoding="UTF-8"?> <configuration status="warn"> <!-- mail server configuration --> <properties> <property name="receipients">me@example.com<

Is log4j2 compatible with Java 11?

☆樱花仙子☆ 提交于 2019-12-01 02:32:46
I tried to run my project on the latest Java 11. Everything works, except the specific file logger. Logging works fine on previous Java versions - 10, 9, 8, but not on Java 11. During server run I see only 1 warning: WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance. Here is my configuration: <Configuration> <Appenders> <RollingFile name="postgresDBLog" fileName="${sys:logs.folder}/postgres.log" filePattern="${sys:logs.folder}/archive/postgres.log.%d{yyyy-MM-dd}"> <PatternLayout> <pattern>%d{HH:mm:ss.SSS} - %msg%n</pattern> </PatternLayout> <Policies

JMX学习以及在log4j中的应用

匆匆过客 提交于 2019-12-01 01:23:47
前言 JMX即Java Managemen Extensions,是一个为应用程序植入管理功能的框架。一套标准的代理和服务,实际上,用户可以在任何Java应用程序中使用这些代理和服务实现管理。 常常在编程的过程中有一些配置信息需要动态的进行改变,我以往会有如下几种做法: 写死在Java code中,环境发生变化的时候修改Java code 写在名为*.properties的配置文件里,使用Java读取配置文件 然而今天我们将引入一种高级的方式来进行配置信息的管理,那便是JMX的引入。 如何使用JMX JMX做为一份规范,JDK中提供了JMX接口,因此安装了JDK后就可以开发基于JMX的代码了。 JMX具有两层结构,各层的组件如下 工具层 Mbeans 通知模型:Notification、NotificationListener Mbeans与数据类:Attribute、Operator 代理层 MBean Server 代理服务 下面学习下log4j2对JMX的支持 JMX-log4j2 Log4j 2 开始支持 JMX. StatusLogger, ContextSelector, 和所有的 LoggerContexts, LoggerConfigs 以及 Appenders 使用了MBeans并且可以被远程检测和控制. 使JMX生效 默认情况下JMX是生效的

How to delete older rolled over log4j2 logs, keeping up to 10 files?

帅比萌擦擦* 提交于 2019-12-01 00:35:11
问题 What I want is: Maximum of 10 log files, in total Each log file, not more than 50MB in size. Thus the logs folder never grows over (50MB *10 )= 500MB. But it seems my log4j2 config is not properly done. What is happening is: Logs do roll over after 50 MB But there are upto 10 logs kept per day Thus there is no limit of number of log files kept in log folder (since for eg, in 2 days, 20 logs of 50mb each have collected) Here is the config: <Configuration status="WARN"> <Appenders> <RollingFile

Different log files for multiple threads using log4j2

拥有回忆 提交于 2019-11-30 23:52:19
I am running a Java application in which I am invoking multiple threads, each with some unique names. Now I want to create multiple log files for each of them and the name of the log files should be as the thread names. Is this possible using log4j2. Please help me write log4j2 configuration files. Thank you in advance. This can be done with the RoutingAppender. The FAQ page has a good example config. I agree a RoutingAppender is the way to go. I initially used the routing appender in conjunction with the ${ctx:threadName} lookup where the 'ctx' uses the ThreadContext. I found that I would

Log4j 2 JSON Configuration

谁说我不能喝 提交于 2019-11-30 21:20:36
I have a configuration in XML that I would like to convert to JSON. The JSON version is not being loaded by Log4j and I cannot find any typos. My test code simply logs an ERROR level and a DEBUG level message. Only ERROR messages are being displayed and no file output is being generated - I'm assuming the framework falls back to the default initialization instead of the JSON file. Note: The log4j2-test.json file is on the classpath. I'm using apache-log4j-2.0-beta9 binary found here . The XML configuration is the following: <?xml version="1.0" encoding="UTF-8"?> <Configuration name="Test">

Log4j2 on Android

让人想犯罪 __ 提交于 2019-11-30 21:05:51
I'm trying to use log4j2 on Android Project (I'm working on Android Studio). In order to simplify this question, I will explaine what I've done in a simple dummy project (I got the same error in the real project than in this dummy project). I create a simple dummy project with a main activity. I add the log4j2 libs... This is the gradle: apply plugin: 'com.android.application' android { packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' } compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "com.example.test20150130" minSdkVersion 19