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

本站现有博文312篇,共被浏览744392

本站已经建立2387天!

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