小编hen*_*mao的帖子

在多线程环境中使用Log4Net

我有一个多线程环境,其中应用程序从WPF启动,它启动2个后台工作线程,一个Web套接字服务器和一个Web API服务器.

我想在一个日志文件中记录所有事件.我正在使用log4Net(第一次).

我正在创建3个Logger实例,并假设文件追加器将理解它必须只写入单个文件.

码:

记录器类:

public class Logger  :ILogger
{
    private static ILog log = null;
    static Logger()
    {
        log = LogManager.GetLogger(typeof(Logger));
        GlobalContext.Properties["host"] = Environment.MachineName;
    }
    public Logger(Type logClass)
    {
        log = LogManager.GetLogger(logClass);
    }

    #region ILogger Members
    public void LogException(Exception exception)
    {
        if (log.IsErrorEnabled)
            log.Error(string.Format(CultureInfo.InvariantCulture, "{0}", exception.Message), exception);
    }
    public void LogError(string message)
    {
        if (log.IsErrorEnabled)
            log.Error(string.Format(CultureInfo.InvariantCulture, "{0}", message));
    }
    public void LogWarningMessage(string message)
    {
        if (log.IsWarnEnabled)
            log.Warn(string.Format(CultureInfo.InvariantCulture, "{0}", message));
    }
    public void LogInfoMessage(string message)
    {
        if (log.IsInfoEnabled)
            log.Info(string.Format(CultureInfo.InvariantCulture, …
Run Code Online (Sandbox Code Playgroud)

c# log4net

5
推荐指数
1
解决办法
1094
查看次数

无法在onClick处理程序的活动类android.view.ContextThemeWrapper中找到onClick(View)方法

我现在不知道我的申请中发生了什么.
我收到此消息Could not find a method onClick(View) in the activity class android.view.ContextThemeWrapper for onClick handler
并且一切正常,我认为......
这是我的活动xml文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#9EC5E2"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:theme="@style/Theme.AppCompat.Light"
    tools:context="com.tumta.henrique.teste.view.LoginActivity">

    <LinearLayout
        android:id="@+id/layout_campos"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="80dp"
            android:text="@string/text_usuario"
            android:textSize="35sp" />

        <EditText
            android:id="@+id/edit_usuario"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="15" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="80dp"
            android:text="@string/text_senha"
            android:textSize="35sp" />

        <EditText
            android:id="@+id/edit_senha"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="15"
            android:password="true" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/layout_campos"
        android:layout_marginTop="50dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/button_ok"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Ok"
            android:onClick="onClick"/>

        <Button
            android:id="@+id/button_cancelar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="30dp" …
Run Code Online (Sandbox Code Playgroud)

android onclick

4
推荐指数
1
解决办法
5156
查看次数

Ajax调用MVC Controller返回"NOT FOUND"

我试图用AJAX调用MVC Controller动作传递一些参数.
我有时在这个应用程序中这样做,它工作正常.
我不知道为什么只有这一个不起作用.

 function excluirDetalhe(button, tab) {
     var index = $(button).closest('tr').index();
     var myTable = document.getElementById(tab);
     var id = myTable.rows[index].cells[0].innerHTML.trim();
     $('#' + tab + ' tr:eq(' + index + ')').remove();
         $.ajax({                
             traditional: true,
             url: "entidades/gravaCookie",
             type: 'post',
             data: { id: id, detalhe: "E" },
             error: function (jqXHR, textStatus, errorThrown) {
                 alert(errorThrown);
             }
     });
 }
Run Code Online (Sandbox Code Playgroud)

这是我的控制器方法:

public void gravaCookie(string id, string detalhe)
{
     string key = "een_id";
     if (detalhe.Equals("E"))
         key = "een_id";
     if (detalhe.Equals("C"))
         key = "eco_id"; …
Run Code Online (Sandbox Code Playgroud)

ajax asp.net-mvc jquery

2
推荐指数
1
解决办法
5015
查看次数

标签 统计

ajax ×1

android ×1

asp.net-mvc ×1

c# ×1

jquery ×1

log4net ×1

onclick ×1