C++ 如何在UNIX中设置Boost.log中的文件权限(用户/组)和访问模式
我希望创建日志文件时始终使用相同的用户/组权限(UNIX),而不是当前正在执行的用户权限。我还想设置文件的访问模式。当我创建日志文件时,我如何才能做到这一点 我正在使用boost库: 可以使用system()命令执行chown()、chgrp()和chmod(),但只能在关闭文件后执行。这不好,因为程序可以运行很长时间C++ 如何在UNIX中设置Boost.log中的文件权限(用户/组)和访问模式,c++,unix,logging,boost,file-permissions,C++,Unix,Logging,Boost,File Permissions,我希望创建日志文件时始终使用相同的用户/组权限(UNIX),而不是当前正在执行的用户权限。我还想设置文件的访问模式。当我创建日志文件时,我如何才能做到这一点 我正在使用boost库: 可以使用system()命令执行chown()、chgrp()和chmod(),但只能在关闭文件后执行。这不好,因为程序可以运行很长时间 #include "Logger.h" using namespace logging::trivial; Logger::Logger(string path, stri
#include "Logger.h"
using namespace logging::trivial;
Logger::Logger(string path, string fileName) {
// TODO Auto-generated constructor stub
this->path = path;
this->fileName = fileName;
logging::add_file_log
(
keywords::file_name = path + "/" + fileName + "_%d.%m.%Y.log", // Name of the Logfile
keywords::open_mode = std::ios_base::app, // is used to attach Events to an existing Logfile
keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0), //is used to create a new Logfile at 12:00pm
keywords::auto_flush = true,
keywords::format =
(
expr::stream
<<expr::format_date_time< boost::posix_time::ptime >("TimeStamp", "[%Y-%m-%d %H:%M:%S]")
<< ": " << expr::smessage)
);// specified the Format "[%TimeStamp%]: %Message%"
}
#包括“Logger.h”
使用名称空间日志::平凡;
Logger::Logger(字符串路径、字符串文件名){
//TODO自动生成的构造函数存根
这->路径=路径;
此->文件名=文件名;
日志记录::添加文件日志
(
关键词::file_name=path+“/”+fileName+“%d.%m.%Y.log”,//日志文件的名称
关键字::open\u mode=std::ios\u base::app,//用于将事件附加到现有日志文件
关键字::基于时间的旋转=汇::文件::旋转在时间点(0,0,0),用于在12:00pm创建新日志文件
关键词::auto_flush=true,
关键词::格式=
(
expr::流