Click here to Skip to main content
15,512,419 members
Home / Discussions / Java
   

Java

 
GeneralRe: Interview Question locking for Ans Pin
Dave Kreskowiak27-Oct-20 7:54
mveDave Kreskowiak27-Oct-20 7:54 
QuestionJAVA IF ELSE STATEMENT (HELP ME) Pin
tomatomoa24-Oct-20 8:45
tomatomoa24-Oct-20 8:45 
AnswerRe: JAVA IF ELSE STATEMENT (HELP ME) Pin
Sandeep Mewara24-Oct-20 9:17
mveSandeep Mewara24-Oct-20 9:17 
GeneralRe: JAVA IF ELSE STATEMENT (HELP ME) Pin
tomatomoa3-Nov-20 3:18
tomatomoa3-Nov-20 3:18 
GeneralRe: JAVA IF ELSE STATEMENT (HELP ME) Pin
Richard MacCutchan3-Nov-20 4:11
mveRichard MacCutchan3-Nov-20 4:11 
QuestionLooking for a node.js developer for advanced disk wiping software (Almost complete) Pin
fixapc22-Oct-20 6:45
fixapc22-Oct-20 6:45 
AnswerRe: Looking for a node.js developer for advanced disk wiping software (Almost complete) Pin
Richard MacCutchan22-Oct-20 7:09
mveRichard MacCutchan22-Oct-20 7:09 
QuestionLog4j2 Migration Pin
Member 1496731916-Oct-20 5:21
Member 1496731916-Oct-20 5:21 
Hi there,

i upgraded the log4j 1.x to log4j2 2.12 Version and therefore changed the xml file.

Here is my log4j2.xml:

---------------------------------------------------
XML
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
	<Appenders>
		<Console name="ConsoleAppender" target="SYSTEM_OUT">
			<PatternLayout> 
				<pattern>%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n</pattern>
			</PatternLayout>
		</Console>
		<RollingFile name="DefaultAppender" fileName="../var/Project-server.log" filePattern="'.'yyyy-MM-dd">
			<PatternLayout> 
				<pattern>%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n"</pattern>
			</PatternLayout>
		</RollingFile>
		<RollingFile name="ErrorAppender" fileName=".../var/Project-server_error.log" filePattern="'.'yyyy-MM-dd">
			<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
			<PatternLayout> 
				<pattern>%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n"</pattern>
			</PatternLayout>
		</RollingFile>
	</Appenders>
	<Loggers>
		<Logger name="com.mchange" level="WARN">
		</Logger>
		<Logger name="com.dwin.Project.common.util" level="WARN">
		</Logger>
		<Logger name="com.dwin.db" level="DEBUG">
		</Logger>
		<Logger name="com.dwin.util" level="DEBUG">
		</Logger>
		<Logger name="org.apache.cxf" level="WARN">
		</Logger>
		<Logger name="org.mortbay" level="WARN">
		</Logger>
		<Logger name="org.springframework" level="INFO">
		</Logger>
		<Root level="DEBUG">
			<AppenderRef ref="DefaultAppender"/>
			<AppenderRef ref="ErrorAppender"/>
			<AppenderRef ref="ConsoleAppender"/>
		</Root>
	</Loggers>
</Configuration>

---------------------------------------------------
Here is the old log4j.xml 1.x:
---------------------------------------------------
XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n"/>
        </layout>
    </appender>
    <appender name="DefaultAppender" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
        <param name="File" value="../var/Project-server.log"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n"/>
        </layout>
    </appender>
    <appender name="ErrorAppender" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
        <param name="File" value="../var/Project-server_error.log"/>
        <param name="threshold" value="ERROR"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{yyyy.MM.dd HH:mm:ss,SSS} %-5p [%t] %c [%X{request} %X{command}] - %m%n"/>
        </layout>
    </appender>
    <logger name="com.mchange">
        <level value="WARN"/>
    </logger>
    <logger name="com.dwin.Project.common.util">
        <level value="WARN"/>
    </logger>
    <logger name="com.dwin.Project.server">
        <level value="DEBUG"/>
    </logger>
    <logger name="com.dwin.db">
        <level value="DEBUG"/>
    </logger>
    <logger name="com.dwin.util">
        <level value="DEBUG"/>
    </logger>
    <logger name="org.apache.cxf">
        <level value="WARN"/>
    </logger>
    <logger name="org.mortbay">
        <level value="WARN"/>
    </logger>
    <logger name="org.springframework">
        <level value="INFO"/>
    </logger>
    <root>
        <level value="DEBUG"/>
        <appender-ref ref="DefaultAppender"/>
        <appender-ref ref="ErrorAppender"/>
        <appender-ref ref="ConsoleAppender"/>
    </root>
</log4j:configuration>

---------------------------------------------------
However i get the following error message when i execute my batch.file:


---------------------------------------------------
2020-10-16 15:40:26,373 main ERROR The parameter is null: policy
2020-10-16 15:40:26,377 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element RollingFile are invalid: field 'policy' has invalid value 'null'
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:208)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:121)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:934)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:579)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:651)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:668)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at com.dwin.Project.server.ProjectServer.<clinit>(ProjectServer.java:10)

2020-10-16 15:40:26,384 main ERROR The parameter is null: policy
2020-10-16 15:40:26,385 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element RollingFile are invalid: field 'policy' has invalid value 'null'
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:208)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:121)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:934)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:579)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:651)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:668)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
at com.dwin.Project.server.ProjectServer.<clinit>(ProjectServer.java:10)

2020-10-16 15:40:26,388 main ERROR Null object returned for RollingFile in Appenders.
2020-10-16 15:40:26,389 main ERROR Null object returned for RollingFile in Appenders.
2020-10-16 15:40:26,398 main ERROR Unable to locate appender "DefaultAppender" for logger config "root"
2020-10-16 15:40:26,399 main ERROR Unable to locate appender "ErrorAppender" for logger config "root"
---------------------------------------------------


Can someone help?
AnswerRe: Log4j2 Migration Pin
Richard MacCutchan16-Oct-20 5:38
mveRichard MacCutchan16-Oct-20 5:38 
QuestionJackson ObjectMapper valueToTree method also write valueType and integral but no actual value Pin
Manish K. Agarwal12-Oct-20 0:02
Manish K. Agarwal12-Oct-20 0:02 
QuestionWhy can't we make a sign up with phone number in android studio project Pin
Member 145474583-Oct-20 3:46
Member 145474583-Oct-20 3:46 
Question2d java graphics Pin
Member 149532531-Oct-20 3:07
Member 149532531-Oct-20 3:07 
AnswerRe: 2d java graphics Pin
CHill601-Oct-20 3:09
mveCHill601-Oct-20 3:09 
AnswerRe: 2d java graphics Pin
Richard MacCutchan1-Oct-20 4:02
mveRichard MacCutchan1-Oct-20 4:02 
Questionjava programmimg Pin
Member 1494135617-Sep-20 20:36
Member 1494135617-Sep-20 20:36 
AnswerRe: java programmimg Pin
Member 1494135617-Sep-20 20:39
Member 1494135617-Sep-20 20:39 
AnswerRe: java programmimg Pin
Sandeep Mewara17-Sep-20 21:23
mveSandeep Mewara17-Sep-20 21:23 
AnswerRe: java programmimg Pin
Gerry Schmitz18-Sep-20 1:44
mveGerry Schmitz18-Sep-20 1:44 
GeneralRe: java programmimg Pin
Dave Kreskowiak18-Sep-20 5:33
mveDave Kreskowiak18-Sep-20 5:33 
QuestionIntegrating keycloak with spring security Pin
arunken16-Sep-20 22:30
arunken16-Sep-20 22:30 
QuestionHelp me! Pin
Member 1492738231-Aug-20 9:30
Member 1492738231-Aug-20 9:30 
AnswerRe: Help me! Pin
ZurdoDev31-Aug-20 10:37
professionalZurdoDev31-Aug-20 10:37 
AnswerRe: Help me! Pin
ZurdoDev31-Aug-20 10:38
professionalZurdoDev31-Aug-20 10:38 
AnswerRe: Help me! Pin
Afzaal Ahmad Zeeshan31-Aug-20 18:52
mveAfzaal Ahmad Zeeshan31-Aug-20 18:52 
AnswerRe: Help me! Pin
Richard MacCutchan31-Aug-20 22:11
mveRichard MacCutchan31-Aug-20 22:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.