Closed ankurnigam closed 2 years ago
I have 500MB of existing file .Is this is the reason it's not working.
I tried with 0 bytes file and extended it till 5 MB still not working
This is a pretty simple case. Try using os.Stat to make sure logdir is pointing where you expect.
logdir is correct this is the reason file is getting recreated and updated as I am passing this variable in lot of functions.
Only thing what I did here is that .
logdir = /home/oracle
and I am running this script as root user using below command :
su oracle -c "script name"
Can it cause function not to work.
Oh hey, you said this file is getting recreated and updated? You can't update the file from other places, or lumberjack won't work. The way lumberjack works is that it tracks how many bytes it has written to the file, and the initial size of the file, so it knows when to roll the file over. If you're changing the file out from under it, it won't work right.
I mean in same program I am calling this file to update logs .So related to directory ,there should not be any issue.
Whatever update is happening it's doing from same program ,there is no manual update in this file or from any other program.
I am suspecting since file location is under /home/oracle and I am running the program using root user "su oracle -c "Program Name"" somehow this lumberjack package is not working.
I am not sure if we have tested this used case.
is data getting written to the file at all? If not, my guess is that it's a permission issue, or either the wrong file is being written to, or you're looking at the wrong file.
Hi Team,
I am passing filename as variable in function but it seems log rotator is not working .Here is the snippet of my code:
logfile := logdir + "/monitoring.log" log.SetOutput(&lumberjack.Logger{ Filename: logfile, MaxSize: 5, // megabytes MaxBackups: 3, })