写日志 log 到文件夹
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace DBUtility
{
public class FileHelper
{
public static void writeLog(string strSQL)
{
try
{
string strFileName = DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
string strPath = "d:/log/";
string strAllPath = strPath + strFileName;
if (!Directory.Exists(strPath))
{
Directory.CreateDirectory(strPath);
}
if (File.Exists(strAllPath))
{
StreamWriter sw = new StreamWriter(strAllPath, true);
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + strSQL); // 写入Hello World
sw.Close(); //关闭文件
}
else
{
FileStream fs = new FileStream(strAllPath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs); // 创建写入流
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + strSQL); // 写入Hello World
sw.Close(); //关闭文件
fs.Close();
}
}
catch (Exception ex) { }
finally { }
}
}
}
Request.UserAgent, Request.UserHostAddress, Request.Browser.Browser
写日志 log 到文件夹的更多相关文章
- time模块目录下自己建立一个名为log的文件夹
使用python调用ping命令,然后在日志中记录ping的结果,用来监测网络连通情况. 代码: [python]from time import *from subprocess import *w ...
- IIS下众多网站,如何快速定位某站点日志在哪个文件夹?
windows2008,iis 多站点, 日志.应用程序池都是默认设置, 没有分开………… Logs目录里面有W3SVC43,W3SVC44,W3SVC45,W3SVC46.....等等日志文件夹. ...
- .net 文件接口的封装,写日志,创建文件log
public class FileSupport { public static FileSupport Instance = new FileSupport(); public static str ...
- 写日志(log)
已下为我自己写的一个写日志的类,比较简洁. <?php class Log { /** * @Purpose : 写日志 * @Method Name : writeLog() * @param ...
- logback将日志写入不同文件夹里
转载:logback不同业务的日志打印到不同文件 一.logback.xml文件配置如下: <?xml version="1.0" encoding="UTF-8& ...
- cocos2d-js 写日志log 查看日志log Android调试查看log
1 输出日志的方式,当然是cc.log了 2 如何查看日志? a)如果小程序可以先在浏览器上跑,例如用chrome,在控制台就可以看到输出的log: b)如果在真机上调试, ...
- log4net 配置允许同时写日志到同一个文件
RollingFileAppender appender = new RollingFileAppender();... appender.LockingModel = new FileAppende ...
- MySQL更改了my.ini的#Path to the database root后,数据还写到原来的文件夹
重新启动数据库 http://www.cnblogs.com/argenbarbie/p/4090494.html
- 在服务器上log4net没写日志
登录到服务器上,发现log4net没写日志 在相应文件夹加上User用户的写权限后恢复正常了.
随机推荐
- Python字符串格式化
一.使用格式化符来格式化字符串: Python支持的所有格式化符 格式化符 意义 'd' 返回要格式化对象的十进制表示,如果可以 'i' 返回要格式化对象的十进制表示,如果可以 'o' 返回要格式化对 ...
- PopupWindowAction breaking MEF import?
If you use Prism InteractionRequest.PopupWindowAction feature, you might have found the MEF Import a ...
- 利用 Serial Over Lan(SOL)搭建 XEN 的调试信息输出环境
如有转载,请注明出处与本文连接,谢谢! 修改XEN的源码实现额外的功能,需要有一个调试环境来得到XEN的调试信息(有关源码编译并安装 XEN 请阅读我以前的博文:在CentOS下源码安装 Xen并搭建 ...
- [liusy.api-SMJ]-创建工程范例 MAVEN archetype 学习阶段(一)
由于这个架构需要好多不同能力的工程,为了创建方便减少冗余,创建工程范例尤为重要 学习阶段: 参考资料 http://maven.apache.org/archetype/maven-archetype ...
- 敏捷项目开源管理软件ScrumBasic(1)
ScrumBasic 是本人基于Asp.net mvc6 最新的core 1.0写的一个敏捷项目管理软件. 目前只是一个基础版本的功能.只支持1个project. 后期会在这个基础上做扩展和权限管理. ...
- NIO SelectionKey中定义的4种事件
SelectionKey.OP_ACCEPT —— 接收连接继续事件,表示服务器监听到了客户连接,服务器可以接收这个连接了 SelectionKey.OP_CONNECT —— 连接就绪事件,表示客户 ...
- js通过隐藏iframe修改session值
js:function selects(id, ss) { window.frames["UpSession"].window.location.href = "../U ...
- HDU 4292:Food(最大流)
http://acm.hdu.edu.cn/showproblem.php?pid=4292 题意:和奶牛一题差不多,只不过每种食物可以有多种. 思路:因为食物多种,所以源点和汇点的容量要改下.还有D ...
- PHP base64
<?php header('Content-type:text/html;charset=utf-8'); function image_base64($image_file) { // get ...
- python :表单验证--对每一个输入框进行验证
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...