-1

In a legacy project I found that in log4j.properties the appender file is defined as:

log4j.appender.file.File=log/logging.log

Where I can find that output file of log4j in linux? At system level the application the logs of "LOG.info" command are not appearing, only the start of its execution

 2022-01-13 11:03:19 INFO  DAGScheduler:54 - Submitting 200 missing tasks from ShuffleMapStage 2 (MapPartitionsRDD[12] at count at appname.java:133) (first 15 tasks are for parti.. ```

***edit: complete log4j properties.:

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

log4j.rootCategory=INFO, console, file

# Set events to be logged to a file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=log/logging.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


# Set everything to be logged to the console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n

# 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=WARN

# 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=WARN
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=WARN

# 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

# Parquet related logging
log4j.logger.org.apache.parquet.CorruptStatistics=ERROR
log4j.logger.parquet.CorruptStatistics=ERROR
  • I can't be certain on Linux, but I don't think it matters. The `log` folder should be a folder relative to the base directory of your code project. From the IDE you might not see it right away (Eclipse is NOTORIOUS for this), so you will have to refresh your project to see it. Also, just because you have a file appender, it doesn't mean that you are actually writing to it. Make sure the Log4J configuration is not just outputting to console. Lastly, if you are using Log4J, I suggest you upgrade to the latest Log4J2 version. – hfontanez Jan 13 '22 at 15:11

2 Answers2

1

There is no log4j specific base path for log4j paths.

If you use a relative file path in the log4j configs, it will be resolved in the same way that all relative file paths are resolved. It will resolved relative to the working directory for the JVM. Loosely speaking, that is "the current directory where you launched the application".

See: How does Java resolve a relative path in new File()?

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
0

Check it:

log4j.appender.stdout.File=${myhome}/log/myapp.log 

Of course, without this statement, check the application's directory.

stackbacon
  • 51
  • 3