if the logs directory doesn't exist, it will throw ex instead of create directory
See original GitHub issuevar transports = [];
transports.push(new winston.transports.DailyRotateFile({
name: 'file',
datePattern: '.yyyy-MM-ddTHH',
filename: path.join(__dirname, "logs", "log_file.log")
}));
var logger = new winston.Logger({transports: transports});
logger.info("current scheduled_mt_task count");
If the subdirectory /logs
doesn’t exist, it will throw exception like can't open file logs/log_file.log20150213XXX
,
I think winston should automatic create the sub directory instead of asking users to manually create it.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:2
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Create a directory if it does not exist and then create the files ...
The Files.createDirectories() creates a new directory and parent directories that do not exist. This method does not throw an exception if the directory...
Read more >Best Practices for exceptions - .NET - Microsoft Learn
Another way to avoid exceptions is to return null (or default) for most common error cases instead of throwing an exception.
Read more >How to Fix the FileNotFoundException in Java.io - Rollbar
The FileNotFoundException is a checked exception in Java that occurs when an attempt to open a file denoted by a specified pathname fails....
Read more >Copy Task - Apache Ant
If false , log a warning message, but do not stop the build, when the file to copy does not exist or one...
Read more >Java Files - java.nio.file.Files Class - DigitalOcean
This method will not throw an exception if the directory could not be created because it already exists. FileAttribute is an optional ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I vote for an option for this. By default the log directory shouldn’t be created, but with an option like
createDirectory
set to true, it would be really convenient if Winston created said directory.@indexzero But why? When you say something like “I think”, you need to provide reasoning for this, no? My reason to have this option is because usually logs directory is not under version control, and will not be created when cloning a repo - boom you have an error when trying to run it. I am not even talking about automatically deployed environments.