我在Raspbian中设置了node-red,我想将来自node-red客户端的日志存储在.log文件等存储位置。
答案 0 :(得分:1)
这可以通过两种方式完成。
答案 1 :(得分:0)
在raspbian上默认安装Node-RED会将其设置为服务,并且日志将已经发送到syslog。
可以使用stories.addDecorator(withKnobs)
.add('Slider', () => {
// create dummy component that wraps the Slider and allows state:
class StoryComp extends React.Component {
constructor( props ){
super(props);
this.state = {
value : this.props.value || 0,
}
}
onValueChange = value => this.setState({ value })
render(){
const props = {.
...this.props,
onValueChange:this.onValueChange, // <--- Reason "StoryComp" is needed
value:this.state.value // <--- Reason "StoryComp" is needed
}
return <Slider {...props} />
}
};
// knobs (customaziable props)
const widthKnobOptions = {
range : true,
min : 200,
max : 1500,
step : 1
}
const props = {
value : number('value', 200000),
min : number('min', 100),
step : number('step', 1000),
max : number('max', 1000000),
width : number('width', 700, widthKnobOptions)
};
return <StoryComp {...props} />
}
);
工具或使用node-red-log
命令来访问日志
答案 2 :(得分:0)
在Linux分发系统中存储节点红色日志的黑客只需遵循以下步骤:-
在 / etc / systemd / system / 中创建自定义节点红色服务
制作.service文件nano /etc/systemd/system/node-red-custom.service
[Unit]
Description=Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways.
After=syslog.target network.target
Documentation=http://nodered.org/
[Service]
#Full Path to Node.js
ExecStart= /usr/bin/node-red
WorkingDirectory=/root/node-red/
# User/Group that launches node-RED (it's advised to create a new user for Node-RED)
# You can do : sudo useradd node-red
# then change the User=root by User=node-red
User=root
Group=root
Nice=10
#SyslogIdentifier=Node-RED
SyslogIdentifier=node-red-custom
StandardOutput=syslog
StandardError=syslog
# Make Node-RED restart if it fails
Restart=on-failure
# Node-RED need a SIGINT to be notified to stop
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
2。制作配置文件,该文件的目标是要将日志存储在何处
nano /etc/rsyslog.d/node-red-custom.conf
if $programname == 'node-red-custom' then /var/log/node-red-logs.log
& stop
创建这两个文件后,请在命令下面运行
sudo systemctl restart rsyslog
sudo systemctl enable node-red-custom.service
sudo systemctl start node-red-custom.service
现在,您的自定义节点红色服务开始将日志存储在 /var/log/node-red-logs.log
中注意:-您必须先终止正在运行的节点红色服务,然后才能如上所述启用自定义节点红色服务。