I wonder why my spring project with tomcat server got catalina.out file with size 40GB. Any solutions, please.catalina.out reach 40 GB
catalina.out reaches such a large size because:
1- there might be many logging messages sent to console handler, and
2- also there is not any rotation of catalina.out (and no policy to remove older catalina.out).
First, as there might be some duplication and the messages in catalina.out , which could also be stored in *log messages too, I'd check if the contents of the log files (catalina.[DATE].log) are the same as those of catalina.out, if so then you can edit file conf/logging.properties and remove console handler
I'd also check the level of the log messages and set a higher level if possible. Look for this line in conf/logging.properties
java.util.logging.ConsoleHandler.level = ....
Possible levels, in increasing level of frequency are SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST or ALL. I'd try replace ALL, FINEST, FINER, FINE by CONFIG or even INFO. For instance, by setting it to INFO, all SEVERE, WARNING and INFO messages will be logged but not any with a level to the right of that list.
Also another option is set a limit to console handler by adding this line to conf/logging.properties
java.util.logging.ConsoleHandler.limit = 1024000
and rotate catalina.out configuring an automatic task to remove older ones.
if you are linux user to handle this from system is pretty easy you can configure logrotation with logrotate this is very easy
Step : 1 (Create Logrotate file)
root#c2dapp01-usea1e# vim /etc/logrotate.d/tomcat
Step : Add rotation instruction for linux log rotator
/opt/tomcat/latest/logs/catalina.out {
copytruncate
daily
rotate 7
compress
missingok
size 100M
}
Step : 3 Add cron job to run daily in crond.daily or create custom cron (This file is by default there if not then only create)
root#c2dapp01-usea1e:# vim /etc/cron.daily/logrotate
# Clean non existent log file entries from status file
cd /var/lib/logrotate
test -e status || touch status
head -1 status > status.clean
sed 's/"//g' status | while read logfile date
do
[ -e "$logfile" ] && echo "\"$logfile\" $date"
done >> status.clean
mv status.clean status
test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf
This script can be run manually.
/usr/sbin/logrotate /etc/logrotate.conf
Most probably the huge size of logs is due to the DEBUG mode setting of log4j. Change this setting to WARN and the size of logging will be reduced.
This is quite common to see catalina.out file expanding.
this could be used to clear the log of catalina.out file without stopping tomcat with the command below.
sudo cat /dev/null > /opt/tomcat/apache-tomcat-9.0.37/logs/catalina.out
To keep catalina.out smaller in size, either one of the following ways can be used:
You could use the above Linux command and add it to a CronScheduler
to run daily/ weekly/ monthly or yearly as preferred.
Use logrotate tool in Linux. It is a log managing command-line tool
in Linux. This can rotate the log files under different conditions.
Particularly, we can rotate log files on a fixed duration or if the
file has grown to a certain size. You can click here for more
info on this.
Related
My company wants us to save logs from the past 3 months. Catalina.out is getting too large on the linux server (Red hat). How can I remove everything in the log except for the last 3 months in the ONE catalina.out file.
I had a requirement slightly similar to you case. This is how I tackled the requirement.
Add following Linux commands into Cron Scheduler
grep the required date stamp i.e. 2022-05-07 and write to new file
grep "2022-05-07" > 2022_05_07.log // write lines which matches the data stamp
wc -l 2022_05_07.log // outputs how many lines captured
Clear the log of catalina.out file without stopping tomcat with the command below.
sudo cat /dev/null > /opt/tomcat/apache-tomcat-9.0.37/logs/catalina.out
Make note it is not recommended to delete the catalina.out while tomcat is running.
It will keep on logging to catalina.out which is removed already (reference of the file is hold by the tomcat) hence the space will not be released. So you will need to restart the tomcat sever to release the space.
pid - 808 just quit unexpectedly, please check logs under /opt/logs/100003171 and /tmp for more information![enter image description here][1]
lsLinHaiZhao ~/Desktop/apollo/apollo-configservice/target/apollo-configservice-2.0.0-SNAPSHOT-github/scripts (master)
$ sh startup.sh
mkdir: cannot create directory ‘/opt’: Permission denied
Windows new JAVA_HOME is: /c/PROGRA~1/Java/JDK18~1.0_4
2022年02月22日 16:18:17 ==== Starting ====
LOG_FOLDER /opt/logs/100003171/ does not exist. Falling back to /tmp
Started [808]
Waiting for server startup.
pid - 808 just quit unexpectedly, please check logs under /opt/logs/100003171 and /tmp for more information!
lsLinHaiZhao ~/Desktop/apollo/apollo-configservice/target/apollo-configservice-2.0.0-SNAPSHOT-github/scripts (master)
$
1.Database password cannot be used: special characters can be used to modify the database password!
2.If the database is not started, the same error will be reported. Restart the database!
3.Not here Configure the contents of relevant databases in the properties file or YML file, and comment out the unnecessary or redundant configuration information, and restart it!
There are three possible mistakes, each of which can lead to the above mistakes. Carefully examine your own problems. Using these three solutions can solve your problems!!!
i have following code i want command line result save in my textfile also how do this. please help
#echo off
set JAVA_HOME=C:\jdk1.5.0_05
set CLI_HOME=c:\projects\utds\applications\cli
set CLI_LIB=%CLI_HOME%\lib
set CLASSPATH=%CLI_LIB%\commons-logging.jar;%CLI_LIB%\commons-logging-api.jar
set CLASSPATH=%CLASSPATH%;%CLI_LIB%\spring.jar;%CLI_LIB%\spring-core.jar;%CLI_LIB%\spring-support.jar;%CLI_LIB%\spring-remoting.jar
set CLASSPATH=%CLASSPATH%;%CLI_LIB%\utds-infra.jar;%CLI_HOME%\src\conf\spring;%CLI_HOME%\src\conf
set CLASSPATH=%CLASSPATH%;%CLI_LIB%\aopalliance.jar
set CLASSPATH=%CLASSPATH%;%CLI_HOME%\dist\cli.jar;%JAVA_HOME%\jre\lib\ext\comm.jar
set path=%JAVA_HOME%\bin;%path%
java -Dport=COM3 -DbaudRate=19200 -Dparser=panasonicCliParser -DappContext=applicationContext-service.xml com.utds.cli.service.comm.CallerIdListener
I would pipe the output of the batch command into a text file by running the following command in the command prompt:
myBatchFile.bat > output.log
Okay it looks like you're trying to put the output of the program into a text file. If that is the case, in your code just add:
java > log.txt
In my opinion, you should better use your logging library. I can see from the script here above that your applications uses Apache's commons-logging and the output shows it is clearly used.
This library is a wrapper indeed. It can use Log4J or JDK's logging library under the hood.
Of course, this requires much more learning and struggling with configuration files but the advantage for you is that you could (following the implementation you chose):
Filter logs following their gravity (debug < info < warning < error...) and/or the classes emitting them. Some libraries are quite verbose .
Create rolling log files : once the the log file reaches a certain size, a new log file can be created and the old one is backup-ed. (It can be possible to limit the number of backups...).
Create a log file per day
Log into databases if you ever need it...
....
add only >mylog.txt Thanks All
java -Dport=COM3 -DbaudRate=19200 -Dparser=panasonicCliParser -DappContext=applicationContext-service.xml com.utds.cli.service.comm.CallerIdListener> mylogs.txt
I've started to make tests, and all the output is sent to a ".log" file. In one test, I have to stop manually the application in a certain line of log.
The question is: Can a .log file work like a Console, displaying info in real time?
You can monitor a log file with tail -f https://en.wikipedia.org/wiki/Tail_%28Unix%29
Within your java code you can monitor its output see java runtime.getruntime() getting output from executing a command line program
or create your own appender How to create a own Appender in log4j?
I'm trying to use 2 commands:
xcodebuild archive -workspace MyProject.xcworkspace -scheme Prod -configuration Prod -archivePath "${WORKSPACE}"/build/MyProject.xcarchive
and
xcodebuild -exportArchive -exportProvisioningProfile "Prov Profile" -exportFormat IPA -exportPath "${WORKSPACE}"/build/MyProject.ipa -archivePath "${WORKSPACE}"/build/MyProject.xcarchive
However, there are way too many lines being logged - around 90k lines or so. normally this isn't a problem, but...
i'm running this on Jenkins, so the log is being logged in JVM memory and i'm getting some weird out of memory exceptions during my jenkins runs (which i think is because somehow with 64 builds, it's showing me 90k lines of logs as opposed to previously 50k lines of logs).
Is there a way to make it so that the logs are silent, until something fails? 90k logs is a LOT of lines to be logging for xcodebuild
I have a hack around this:
have the output be piped to a file on the jenkins server, and tail -f that file to get the logs. you can then even email that tail (if the command had succeeded).
that way, you avoid logging into console, instead you log to file.
something like:
xcodebuild archive -workspace MyProject.xcworkspace -scheme Prod -configuration Prod -archivePath "${WORKSPACE}"/build/MyProject.xcarchive > ~/dzt/tmp/archive_results.txt