Open isakar opened 8 years ago
nar
executables is a bash process that creates a child process to run the node
process. You're issue could be related to OS specific processes? In terms of logging, you should be able to write log entries into a file or to stderr
/stdout
stream without problems.
I am using a mac with OS X El Capitan and the final deploy would be over Amazon C2 server. The log file would be created in the same level as the routes folder but in a log folder and log4js creates the file where I specify in a configuration section with 'filename' parameter. I have something like this: config.js
var log4js = require('log4js');
log4js.loadAppender('file');
log4js.configure({
appenders: [
{ type: 'file',
filename: "./logs/pbws.log",
category: 'Logs',
maxLogSize: 20480,
backups: 10
}
]
});
var logger;
var getLogger = function(name, callback){
logger = log4js.getLogger(name);
logger.setLevel("Logs");
callback(logger);
};
exports.getLogger = getLogger;
In other files I use this like:
var config = require('./config');
var logger;
config.getLogger("NameX", function(log){
logger = log;
});
logger.debug('My text for the log file');
Also, I am doing another quick test with this example:
var fs = require('fs');
var stream = fs.createWriteStream("MyFile.txt");
stream.once('open', function(fd) {
stream.write("Row 1 writing\n");
stream.write("Next row\n");
stream.end();
});
But the file doesn't create anywhere when I run the project with NAR. So the issue is not just the Log4js, is probably the paths mapping.
@isakar you can use lsof -p <pid of nar run>
to see what files (with full path) are open
I can see this in the console: node 50478 SakarI 22w REG 1,4 2752 15317040 /private/var/folders/79/pybn74xx6h9f97v3s_4m54cc0006by/T/nar-PictureBookWS-0.0.1-1462473651036/logs/pbws.log
Actually is the name of my log, but I don't know how could I get it. I mean, if I search in the entire computer, it doesn't find the file in nowhere.
Use an absolute path or an explicit extraction path. nar
by defaults extracts files in .nar
hidden folder.
Hi, I have a project in which I am using log4js to track the processes in a log file and it works fine without NAR package, but when I create the package with NAR (I added all my dependencies in package.json) and execute it, the project still runs well but the there is no log file and It doesn't show an error, nothing to tell me what could be is happening. Do you have any thought about it?