Runnig Ex-crawler - log4j

Hi i am runnig the jar of this open source Ex-Crawler
But i always receive this error :
og4j:WARN No appenders could be found for logger (eu.medsea.mimeutil.TextMimeDetector).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info

The application you're running uses log4j to produce log files. And log4j needs a configuration file, usually named log4j.properties, to be available in the application's class path, in order to start properly.
This is sample of default configuration you might start with:
log4j.rootLogger=WARN, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n

Related

log4j-1.2-api bridge ClassNotFoundException:org.apache.log4j.RollingFileAppender

I try to migrate my application from log4j to log4j2. According to official manual I have org.apache.logging.log4j:log4j-1.2-api:2.17.1, org.apache.logging.log4j:log4j-api:2.17.1 and org.apache.logging.log4j:log4j-core:2.17.1 in my maven dependencies. I use log4j.properties file so I enabled compatibility mode (-Dlog4j1.compatibility=true). RollingFileAppender is configured in my log4j.properties file:
log4j.appender.A2=org.apache.log4j.RollingFileAppender
I get following error:
2022-02-16 21:04:20,396 main ERROR Unable to create Appender org.apache.log4j.RollingFileAppender due to ClassNotFoundException:org.apache.log4j.RollingFileAppender
According to official manual, RollingFileAppender is a supported component. I had log4j:log4j:1.2.17 dependency before migration to log4j2 and it contains org.apache.log4j.RollingFileAppender class. Unfortunately none of the log4j-1.2-api,log4j-api and log4j-core libraries contain this class. I do not understand why RollingFileAppender is not present in log4j bridge if manual says that RollingFileAppender is supported component. I have found similar question but without a satisfactory answer. How to migrate RollingFileAppender?
UPDATE
Here is my log4j.properties file:
log4j.rootCategory=INFO, A1, A2
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A2=org.apache.log4j.RollingFileAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d%m%M %n
log4j.appender.A2.file=C:/projects/test/Log.log
#log4j.appender.A2.layout=org.apache.log4j.PatternLayout
#log4j.appender.A2.layout.ConversionPattern=[%d{dd.MM HH.mm.ss.SSS} %-5p %-20c{1}] : %m%n
#log4j.appender.A2.MaxFileSize=10000KB
#log4j.appender.A2.MaxBackupIndex=3
I added -Dlog4j2.debug=true. There are tons of logs. I chose interesting logs:
TRACE StatusLogger Trying to find [log4j.properties] using context class loader jdk.internal.loader.ClassLoaders$AppClassLoader#2437c6dc.
DEBUG StatusLogger Not in a ServletContext environment, thus not loading WebLookup plugin.
DEBUG StatusLogger PluginManager 'Log4j Builder' found 18 plugins
DEBUG StatusLogger Parsing for [root] with value=[INFO, A1, A2].
DEBUG StatusLogger Level token is [INFO].
DEBUG StatusLogger Logger root level set to INFO
DEBUG StatusLogger Parsing appender named "A1".
DEBUG StatusLogger PluginManager 'Converter' found 47 plugins
DEBUG StatusLogger Starting OutputStreamManager SYSTEM_OUT.false.false
DEBUG StatusLogger Adding appender named [A1] to loggerConfig [].
DEBUG StatusLogger Parsing appender named "A2".
WARN StatusLogger Unable to create File Appender, no file name provided
ERROR StatusLogger Unable to create Appender org.apache.log4j.RollingFileAppender due to ClassNotFoundException:org.apache.log4j.RollingFileAppender
DEBUG StatusLogger Appender named [A2] not found.
DEBUG StatusLogger Finished configuring.
The reason configuration fails is explained by the following message:
WARN StatusLogger Unable to create File Appender, no file name provided
This is caused by a compatibility problem between the Log4j 1.x bridge and the original Log4j 1.x: property names must start with a capital letter (cf. LOG4J2-3316). This will be solved in the next release.
Until then, you can use:
log4j.appender.A2.File=C:/projects/test/Log.log
(with a capital F).

Getting error from Log4j.properties log4j:WARN No such property [maxFileSize] in org.apache.log4j.FileAppender

log4j:WARN No such property [maxBackupIndex] in org.apache.log4j.FileAppender.
log4j:WARN No such property [maxFileSize] in org.apache.log4j.FileAppender.
What does this mean, what causes it, and how should you fix it?
# initialize root logger with level ERROR for stdout and file
log4j.rootLogger=DEBUG,stdout,file
# set the log level for these components
log4j.logger.com.endeca=DEBUG
log4j.logger.com.endeca.itl.web.metrics=INFO
# add a ConsoleAppender to the logger stdout to write to the console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# use a simple message format
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# add a FileAppender to the logger file
log4j.appender.file=org.apache.log4j.FileAppender
# create a log file
log4j.appender.file.File=E:\\temp\\GAPN.log
# take backup periodically
log4j.appender.file.MaxFileSize=2KB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
# use a more detailed message pattern
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
The appender 'file' is of type FileAppender. FileAppender does not have a field MaxFileSize. This is a property of RollingFileAppender class, which is a subclass of FileAppender and allows for log rotation based on size.

Pyspark and Log4J configuration

I'm trying to have some decent logging through Python using log4j.
I want to have all logs written to a DB, only errors written to an error.log file, and only info written to an info.log file.
logger = sc._jvm.org.apache.log4j
lg = logger.LogManager.getRootLogger()
lg.info('test')
lg.error('test')
lg.debug('test')
lg.fatal('test')
and my log4j.properties file is as follow:
# Set everything to be logged to the console
log4j.rootLogger=INFO, ria_info, ria_error, ria_mysql, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%p] %d %c %M - %m%n
# Set info logs to be written to info file
log4j.appender.ria_info=org.apache.log4j.RollingFileAppender
log4j.appender.ria_info.filter.RangeFilter=org.apache.log4j.varia.LevelMatchFilter
log4j.appender.ria_info.filter.RangeFilter.LevelToMatch=INFO
log4j.appender.ria_info.filter.RangeFilter.AcceptOnMatch=true
log4j.appender.ria_info.layout=org.apache.log4j.PatternLayout
log4j.appender.ria_info.layout.ConversionPattern=[%p] %d %c %M - %m%n
log4j.appender.ria_info.File=/home/data/logs/info.log
log4j.appender.ria_info.MaxFileSize=10MB
log4j.appender.ria_info.MaxBackupIndex=10
log4j.appender.ria_error=org.apache.log4j.RollingFileAppender
log4j.appender.ria_error.Append=false
log4j.appender.ria_error.filter.RangeFilter=org.apache.log4j.varia.LevelMatchFilter
log4j.appender.ria_error.filter.RangeFilter.LevelToMatch=ERROR
log4j.appender.ria_error.filter.RangeFilter.AcceptOnMatch=true
log4j.appender.ria_error.layout=org.apache.log4j.PatternLayout
log4j.appender.ria_error.layout.ConversionPattern=[%p] %d %c %M - %m%n
log4j.appender.ria_error.File=/home/data/logs/error.log
log4j.appender.ria_error.MaxFileSize=10MB
log4j.appender.ria_error.MaxBackupIndex=10
log4j.appender.ria_mysql=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.ria_mysql.URL=jdbc:mysql://localhost/DB
log4j.appender.ria_mysql.driver=com.mysql.jdbc.Driver
log4j.appender.ria_mysql.user=xxxx
log4j.appender.ria_mysql.password=xxxxx
log4j.appender.ria_mysql.sql=INSERT INTO LOGS VALUES('%p','%d{yyyy-MM-dd HH:mm:ss}','%t','%x','%c','%m')
log4j.appender.ria_mysql.layout=org.apache.log4j.PatternLayout
# Set the default spark-shell log level to WARN. When running the spark-shell, the
# log level for this class is used to overwrite the root logger's log level, so that
# the user can have different defaults for the shell and regular Spark apps.
log4j.logger.org.apache.spark.repl.Main=INFO
# Settings to quiet third party logs that are too verbose
log4j.logger.org.spark_project.jetty=WARN
log4j.logger.org.spark_project.jetty.util.component.AbstractLifeCycle=ERROR
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO
log4j.logger.org.apache.parquet=ERROR
log4j.logger.parquet=ERROR
# SPARK-9183: Settings to avoid annoying messages when looking up nonexistent UDFs in SparkSQL with Hive support
log4j.logger.org.apache.hadoop.hive.metastore.RetryingHMSHandler=FATAL
log4j.logger.org.apache.hadoop.hive.ql.exec.FunctionRegistry=ERROR
Now I get the error and fatal 'test' message in my DB and error.log. But the info and debug message gets completely lost for some reason. Also lg.isInfoEnabled() returns False.
I tried a lot of stuff around additivity but it didn't seem to solve the problem.

TIBCO MDM 9 : log4j:WARN No appenders could be found for logger (RulebaseCustomFunction)

Getting below error while I am trying to print MqLog to elink.log via RulebaseCustomFunction (MDM 9)\
ERROR [stderr] (TIBCO EMS Session Dispatcher (895)) log4j:WARN No appenders could be found for logger (RulebaseCustomFunction).
ERROR [stderr] (TIBCO EMS Session Dispatcher (895)) log4j:WARN Please initialize the log4j system properly.
How to Configure in order to avoid above error?
Can somebody help me, please?
Default log4j configuration provided out-of-box does not have appender defined for RulebaseCustomFunction. However, you can always add new appender to ConfigValues.xml
Try adding below in "Logging" category-
<ConfValue description="The debugging logging level CustomRulebaseFunction" name="Logging Level for CustomRulebaseFunction" propname="log4j.logger.RulebaseCustomFunction" sinceVersion="8.0" visibility="All" isHotDeployable="true" isHidden="false">
<ConfString default="DEBUG,elink,error" value="DEBUG,elink,error"/>
</ConfValue>

JAX-WS - Out of memory?

i call a simple endpoint-method from client.
MyStatus getStatus(Car car) throws NoSuchCarException;
what i got is:
java.lang.OutOfMemoryError: PermGen space
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:317)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:146)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:129)
at $Proxy124.getStatus(Unknown Source)
at de.Babs.showState(Babs.java:622)
What is the problem?
How can i activate xml-logging from JAX comunication?
The problem might be that there are two many applications deployed into your container or application server. java.lang.OutOfMemoryError: PermGen space is more due to system's limitation (memory) rather than due to programming mistakes. For e.g. it could mean that there is not enough memory for some resources to be loaded. Make sure you restart your server after each deployment or redeployment.
To enable logging just put needed log4j or slf4j or whatever framework you are using to server 's global libraries, then create a log4j.properties file like this (if you're using log4j):
log4j.rootLogger=INFO,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %X{file} %c{1} - %m%n
####################### YourService ######################
log4j.logger.com.yourservice.servicename=DEBUG,servicename
log4j.additivity.com.yourservice.servicename=false
log4j.logger.servicename=DEBUG,servicename
log4j.additivity.servicename=false
log4j.appender.servicename=org.apache.log4j.DailyRollingFileAppender
log4j.appender.servicename.File=C:\\Servers\\glassfish-3.1.2\\gf-app-logs\\servicename.log
log4j.appender.servicename.DatePattern='.'yyyy-MM-dd
log4j.appender.servicename.layout=org.apache.log4j.PatternLayout
log4j.appender.servicename.layout.ConversionPattern=%d [%t] %-5p %X{file} %c{1} %m%n
log4j.appender.servicename.ImmediateFlush=true
########################################################
I was using glassfish 3, all the logging appeared in this file: C:\\Servers\\glassfish-3.1.2\\gf-app-logs\\servicename.log. For e.g. in glassfish 3, this log4j.properties file, needs to be added into: &{base.dir}\glassfish-3.1.2\glassfish3\glassfish\domains\domain1\config

Resources