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

本站现有博文321篇,共被浏览764598

本站已经建立2442天!

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