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 到文件夹的更多相关文章

  1. time模块目录下自己建立一个名为log的文件夹

    使用python调用ping命令,然后在日志中记录ping的结果,用来监测网络连通情况. 代码: [python]from time import *from subprocess import *w ...

  2. IIS下众多网站,如何快速定位某站点日志在哪个文件夹?

    windows2008,iis 多站点, 日志.应用程序池都是默认设置, 没有分开………… Logs目录里面有W3SVC43,W3SVC44,W3SVC45,W3SVC46.....等等日志文件夹. ...

  3. .net 文件接口的封装,写日志,创建文件log

    public class FileSupport { public static FileSupport Instance = new FileSupport(); public static str ...

  4. 写日志(log)

    已下为我自己写的一个写日志的类,比较简洁. <?php class Log { /** * @Purpose : 写日志 * @Method Name : writeLog() * @param ...

  5. logback将日志写入不同文件夹里

    转载:logback不同业务的日志打印到不同文件 一.logback.xml文件配置如下: <?xml version="1.0" encoding="UTF-8& ...

  6. cocos2d-js 写日志log 查看日志log Android调试查看log

    1 输出日志的方式,当然是cc.log了 2 如何查看日志?        a)如果小程序可以先在浏览器上跑,例如用chrome,在控制台就可以看到输出的log:        b)如果在真机上调试, ...

  7. log4net 配置允许同时写日志到同一个文件

    RollingFileAppender appender = new RollingFileAppender();... appender.LockingModel = new FileAppende ...

  8. MySQL更改了my.ini的#Path to the database root后,数据还写到原来的文件夹

    重新启动数据库 http://www.cnblogs.com/argenbarbie/p/4090494.html

  9. 在服务器上log4net没写日志

    登录到服务器上,发现log4net没写日志 在相应文件夹加上User用户的写权限后恢复正常了.

随机推荐

  1. 【003:switch 不加 break的结果

    #include <stdio.h> int main(){ char ch = 's'; switch(ch){ case 'a':{ printf("aaaaa") ...

  2. Infinite loop when using cookieless session ID on Azure

    If you use cookieless session ID and deploy them on Azure, you might get infinite loop when you quer ...

  3. zabbix

    snmp监控服务器客户端需安装net-snmp net-snmp-utils 然后修改/etc/snmp/snmpd.conf 启动snmpd服务 自定义监控项目:需在agent端的zabbix_ag ...

  4. RabbitMQ高可用方案总结

    RabbitMQ的集群方案有以下几种: 1.普通的集群 exchange,buindling再所有的节点上都会保存一份,但是queue只会存储在其中的一个节点上,但是所有的节点都会存储一份queue的 ...

  5. QT的信号和槽

    QObject::connect(&dummy, SIGNAL(sig()), &thread, SLOT(slot_main())); 这里slot_main()是thread类中的 ...

  6. iOS中什么是superView?(新手概念简述版)

    文/司马陶冶(简书作者)/文章有删改原文链接:http://www.jianshu.com/p/8537dac37852 著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”. 在iPhone ...

  7. 非本地跳转之setjmp与longjmp

    非本地跳转(unlocal jump)是与本地跳转相对应的一个概念. 本地跳转主要指的是类似于goto语句的一系列应用,当设置了标志之后,可以跳到所在函数内部的标号上.然而,本地跳转不能将控制权转移到 ...

  8. Js控制Div在浏览器中的高度

    //需求是,我需要通过浏览器内容可视化的高度来控制div的高度boxheight(); //执行函数function boxheight(){ //函数:获取尺寸 //获取浏览器窗口高度 var wi ...

  9. python之RabbitMQ

    一.安装RabbitMQ 1. 安装erlang 1 2 3 4 tar xf otp_src_18.3.tar.gz cd otp_src_18.3 ./configure --prefix=/ma ...

  10. markdown 标识语言

    打算改用markdown标记语言来写blog,特地收集了些相关的资料: 基本介绍: markdown 语法说明简明版 markdown 语法说明完整版 一些相应的资料: 知乎上相关的问题解答 mark ...