EADST

Print Info in the Terminal and Save Logs in a File

Print Info in the Terminal and Save Logs in a File

import logging

log_name = "test"
logging.basicConfig(filename="{}.log".format(log_name), format='%(asctime)s %(message)s', filemode='w') 
sh = logging.StreamHandler()
logger=logging.getLogger() 
logger.setLevel(logging.DEBUG) 
logger.addHandler(sh)

logger.debug("Level lowest message") 
logger.info("Regular message") 
logger.warning("Warning message") 
logger.error("Error message") 
logger.critical("Fatal message") 

Reference

Python Logging

相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
搞笑 CSV Plotly 财报 Tracking Plate Conda 算法题 Windows Rebuttal EXCEL 继承 Random CUDA Pickle Diagram uwsgi Quantization Magnet GIT ResNet-50 Land BF16 SPIE API Qwen LaTeX 版权 Paper SVR QWEN Numpy Attention PIP GPT4 Miniforge Template 图标 Permission 腾讯云 CC Streamlit VGG-16 Crawler Paddle Domain WAN ModelScope Jupyter Video Tiktoken XML Qwen2 第一性原理 BeautifulSoup Heatmap llama.cpp NLTK GoogLeNet GPTQ 阿里云 ONNX 多进程 Agent DeepStream Website Pandas XGBoost VPN Git Translation git FP16 DeepSeek Algorithm Excel Password tqdm Knowledge TensorRT LeetCode OpenAI OCR mmap Tensor UI uWSGI SQL Data Ubuntu COCO 净利润 多线程 Datetime git-lfs 证件照 Markdown Qwen2.5 Proxy Bitcoin FP32 LLAMA Math WebCrawler Base64 InvalidArgumentError Clash RAR Distillation FP64 Animate Freesound Image2Text Zip Search Bert v2ray Jetson Hungarian scipy AI JSON Color GGML Mixtral Quantize 递归学习法 LoRA 公式 Web 域名 音频 FlashAttention Hotel 顶会 Vim Firewall LLM Sklearn IndexTTS2 CAM icon 强化学习 tar MD5 Hilton Nginx diffusers OpenCV PyTorch 签证 hf NameSilo 报税 SAM TensorFlow 关于博主 logger Breakpoint PyCharm printf CTC Ptyhon Google Michelin Bipartite Pillow Pytorch Python ChatGPT Anaconda Bin FastAPI NLP News PDF Statistics Food Vmess Dataset VSCode Baidu UNIX 图形思考法 Django CV RGB Review 云服务器 飞书 Docker Use Shortcut Disk BTC Card TTS Gemma Interview TSV Input YOLO FP8 Github v0.dev Transformers Cloudreve CLAP C++ Claude Safetensors HuggingFace transformers Augmentation SQLite Linux torchinfo Llama CEIR PDB HaggingFace Logo
站点统计

本站现有博文323篇,共被浏览795422

本站已经建立2493天!

热门文章
文章归档
回到顶部