我在哪里可以找到我的 Electron 应用程序在生产环境中的日志?
Where can I find the logs for my Electron app in production?
我已经使用 Electron and used Electron-Builder to create a Squirrel windows 安装程序和更新程序构建了一个应用程序。一切都很好,但我在调试我的应用程序的生产版本时遇到了问题。
使用生产版本时,console.log
创建的日志是否写入磁盘的某处?如果是这样,我在哪里可以找到它们?还是在编译可执行文件时将它们全部删除?我的应用程序一定有某种日志文件吧?
我在 C:\Users\Tieme\AppData\Local\MyApp\SquirrelSetupLog
中找到了 SquirrelSetupLog,但这不足以调试我的纯生产问题。
刚遇到electron-log。如果确实没有将常规控制台日志写入磁盘某处,那可能会起作用..
如果您指的是 Web 应用程序中的控制台,则适用:)
您需要进行回调才能使其正常工作。在这里阅读更多关于它们的信息:http://electron.atom.io/docs/api/remote/
这是一个简短的例子:
在你的电子 main.js
旁边的一个名为 logger.js
的文件中,添加此代码:
exports.log = (entry) => {
console.log(entry);
}
然后在你的webapp中,使用这个来调用这个日志方法回调:
// This line gets the code from the newly created file logger.js
const logger = require('electron').remote.require('./logger');
// This line calls the function exports.log from the logger.js file, but
// this happens in the context of the electron app, so from here you can
// see it in the console when running the electron app or write to disk.
logger.log('Woohoo!');
您可能还想查看 https://www.npmjs.com/package/electron-log 的 "better" 日志记录和写入磁盘。但是你总是需要使用回调。
我已经使用 Electron and used Electron-Builder to create a Squirrel windows 安装程序和更新程序构建了一个应用程序。一切都很好,但我在调试我的应用程序的生产版本时遇到了问题。
使用生产版本时,console.log
创建的日志是否写入磁盘的某处?如果是这样,我在哪里可以找到它们?还是在编译可执行文件时将它们全部删除?我的应用程序一定有某种日志文件吧?
我在 C:\Users\Tieme\AppData\Local\MyApp\SquirrelSetupLog
中找到了 SquirrelSetupLog,但这不足以调试我的纯生产问题。
刚遇到electron-log。如果确实没有将常规控制台日志写入磁盘某处,那可能会起作用..
如果您指的是 Web 应用程序中的控制台,则适用:)
您需要进行回调才能使其正常工作。在这里阅读更多关于它们的信息:http://electron.atom.io/docs/api/remote/
这是一个简短的例子:
在你的电子 main.js
旁边的一个名为 logger.js
的文件中,添加此代码:
exports.log = (entry) => {
console.log(entry);
}
然后在你的webapp中,使用这个来调用这个日志方法回调:
// This line gets the code from the newly created file logger.js
const logger = require('electron').remote.require('./logger');
// This line calls the function exports.log from the logger.js file, but
// this happens in the context of the electron app, so from here you can
// see it in the console when running the electron app or write to disk.
logger.log('Woohoo!');
您可能还想查看 https://www.npmjs.com/package/electron-log 的 "better" 日志记录和写入磁盘。但是你总是需要使用回调。