in my nodejs logging i am using winston daily rotate file module and it works very well, however i have a question about file naming: is that possible to not have datePattern in the current file name but adding it once it got daily rotated over?
example:
my_log.log ----- current one
my_log_2017-10-18.log -----yesterday
my_log_2017-10-17.log ----- the day before yesterday
Related
I have a log file which is used by grafana for graphing and searching logs by me.
Now using daily rotate I can rotate log files and zip but I want to keep the logs of previous month.
For eg. If now its March, I need February logs present in the file but Jan logs to be zipped.
As winston Daily rotate will create a new blank file which will make my work difficult to debug last month errors.
"winston": "version": "2.3.1"
npm --version: 6.14.6
New to node.js. My requirement is to change file name of a CSV file to a different path (new file) every day at 15 minutes past midnight. Presently using fast-csv to write the output. How can I change the path of the file dynamically to another path and CSV file at the above mentioned time, such that the new file takes over the writing of output and the previous one is saved and closed. How can I accomplish this?
Edit: I can use node-schedule for the scheduling part.
For the time use https://www.npmjs.com/package/node-schedule
var event = schedule.scheduleJob("0 15 0 * * 0-6", function() {
yourFunctionToChangeTheCSVPath();
});
This should be 15 past midnight.
Hi I have a file name like this. I would like to remove the date part from the file name daily before my load and append the date after the load gets completed. How would I be able to achieve that?.
file name:-
zip_cost_03_08_2018 21_13_04.csv
I need the file name like below before my load starts
zip_cost.csv
I need to append the date back once my load gets completed.
zip_cost_03_08_2018 21_13_04.csv
You can get the timestamp in the format you want by using the date command.
$ date "+%m_%d_%Y_%H_%M_%S"
03_09_2018_09_21_40
So with that, you can just do -
mv "zip_cost_03_08_2018 21_13_04.csv" zip_cost.csv
# Run the load operation
mv zip_cost.csv "zip_cost_$(date '+%m_%d_%Y_%H_%M_%S').csv"
I have make my properties file ok,but what should I do if I want to put the log file in a folder relate to the date?
For example,today is 12/29 2015,at 10:30,I started my java project,the log4j.propertites about the log like the following ones:
log4j.appender.inforlog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.inforlog.DatePattern='.'yyyy-MM-dd-HH
log4j.appender.inforlog.File=D:/inforLogs/2015/12/searchrecord
when it comes to 11:00,there will be a log file named searchrecord.2015-12-29-10 in "D:/inforLogs/2015/12/", when it comes to 01/01 2016,the log file will alse in file "D:/inforLogs/2015/12/",but I want to make it in file "D:/inforLogs/2016/01/" by write the properties file properly,what should I do?
I have resolve the problem myself,here is the properties file
log4j.appender.inforlog.DatePattern='s/'yyyy'/'MM'/searchrecord-'dd'_'HH'.log'
log4j.appender.inforlog.File=D:/inforLog
I have a webcam that uploads a pic to a webpage every 5 minutes and beneath it is some code to upload a timestamp. Recently I have noticed the timestamp is an hour out and Ive checked the linux server, webcam taking images and they have the correct time so not sure what has happened. I suspect its some daylight saving issue but I cant find it so just want to do a temp fix for now.
Heres the code I use to timestamp the image, how can I add an hour onto this? Everything I have tried just results in it not showing the timestamp at all?
echo "- Image Uploaded: " . date ("F d Y H:i:s", filemtime($filename));
Assuming this is php, you can set a timezone in your script
with eg
date_default_timezone_set('Europe/Amsterdam');
See here for the list of timezones.