这是代码,我正在从app.json文件中加载配置,如您所见, file_load 正在从位置获取文件并使用dictConfig我正在获取有关日志记录处理程序,格式化程序等的信息。试图从多个实例中写入名为 log.json 的同一文件,但出现 windowspermission错误。任何人都知道什么,请帮助我。
render() {
return (
<div style={{ paddingTop: 64 }}>
<AppBar>
<Toolbar>
<Typography variant="title" color="inherit">
Title
</Typography>
</Toolbar>
</AppBar>
<YourComponent />
</div>
);
}
以下是运行代码后出现的错误。
# Try to importing modules
try:
import logging
from logging import config, Formatter, Handler
import json
import os
import traceback
from threading import Thread
import time
import sys
import multiprocessing
from multiprocessing import Process, Semaphore, SimpleQueue, Lock, Event, Manager, current_process, BoundedSemaphore
# if modules can not be installed than raise an Exception.
except Exception as e:
print("Exception occured installing modules", e)
# class logger to print the data in file calling methods.
class Logger:
# when create any object of logger class it will
def __init__(self):
# self.semaphore = Semaphore(10)
self.queue = multiprocessing.Queue()
file_load = open('C:/Users/desaijb/Desktop/gitpractice/gitpractice/test_log/app.json')
config_file = json.load(file_load)
final_config_file = config_file['logging']
config.dictConfig(final_config_file)
self.logger = logging.getLogger()
def debug(self, message):
logging.getLogger('debug_module')
self.queue.put(message)
# self.semaphore.acquire()
# self.logger.debug(message)
# self.semaphore.release()
return True
def info(self, message):
logging.getLogger('info_module')
self.logger.info(message)
return True
def warning(self, message):
logging.getLogger('warning_module')
self.logger.warning(message)
def error(self,message):
logging.getLogger('error_module')
self.logger.error(message)
def critical(self, message):
logging.getLogger('critical_module')
self.logger.critical(message)
def receive(self):
while self.queue:
received_message = self.queue.get()
if __name__ == "__main__":
logg = Logger()
proc = Process(target=logg.debug, args=('message',))
proc.start()