c # – Configure the Serilog file sink in the application configuration to use a log file per application run

I want a new log file to be created every time my application runs.

I have read the answer to a similar question asked here, however, this answer applies to the Serilog configuration in the C # code, while I want to configure it in my application settings.

How can I configure Serilog through my application settings, so that I create a new file every time the application runs?

My current configuration:

    "Serilog": {
        "Using":  ("Serilog.Sinks.File"),
        "MinimumLevel": "Debug",
        "WriteTo": (
            { 
            "Name": "File",
            "Args": { 
                "path": "Logs/MyAppLog.txt" ,
                "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} ({Level}) ({SourceContext}) {Message}{NewLine}{Exception}",
                "rollingInterval" : null // Throws ArgumentException
                "retainedFileCountLimit": null // Does nothing
                }
            }
        ),
        "Enrich": ("FromLogContext", "WithMachineName", "WithThreadId"),
        "Properties": {
            "Application": "TetriSharp.Application"
        }
      }

As a related question, is it possible to add a date and time to the file name that Serilog creates? Ideally, I need to include the date and time with seconds and milliseconds, since it is possible for the application to run twice in the same second (although unlikely). The file name format specifiers mentioned in the Readme file do not work, as they result in the string {Hour}, {HalfHour} etc. It is included in the file name. Also, they don't seem to include seconds / milliseconds.

Any ideas?

enterprise sharepoint: the event sink could not add items to the list

I have an event receiver to process an Excel file and insert rows into another SharePoint list.

I receive the following error when I add the item to the list.

The request for execution of isolated space code was rejected because the isolated space
The Code Host Service was too busy to handle the request

I tried to override resource use restrictions using the following PowerShell, but still had no luck.

$uc = (Microsoft.SharePoint.Administration.SPUserCodeService)::Local
$uc.WorkerProcessExecutionTimeout = 5000
$uc.Update()

$tier = $uc.Tiers("")   # default Tier has no Name
$tier.MaximumWorkerProcesses = 2    # number of CPU Cores + 1
$tier.Update()

I develop this event receiver as a farm solution and I am really confused about why the event receiver looks for Sandboxed Services.

How to publish to an external API within a SharePoint event sink

I currently have an EventReceptor for when an item is updated. Add some values ​​in the element fields. No problem.

However, when I add the part I really need (publish those values ​​elsewhere) it breaks. I simply need to pass those two fields to a remote endpoint. If I delete that internal test capture that the post does, everything works fine and my fields are updated.

Any ideas?

Is this allowed in an event receiver? Is there a better way to do it?

using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
using System.Net;
using System.Collections.Specialized;
using System.Text;
namespace DocumentLibrary.BRCS_EventReceiver
{
/// 
/// List Item Events
/// 
public class BRCS_EventReceiver : SPItemEventReceiver
{
    /// 
    /// An item was added.
    /// 
    public override void ItemAdded(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);
    }

    /// 
    /// An item was updated.
    /// 
    /// 
    public override void ItemUpdated(SPItemEventProperties properties)
    {

        base.ItemUpdated(properties);
        string fullDocPath = "";
        string fullDocID = "";
        string responsebody = "hello";
        try
        {
            using (SPWeb web = properties.OpenWeb())
            {
                SPListItem currentItem = properties.ListItem;
                string currentSiteURL = properties.ListItem.Web.Site.Url;
                fullDocPath = currentSiteURL + "/" + currentItem.Url;
                fullDocID = properties.ListItemId.ToString();
                currentItem("MajorCategory") = fullDocPath;

                currentItem("MinorCategory") = "id: " + fullDocID;
                try
                {
                    using (var client = new WebClient())
                    {
                        NameValueCollection values = new NameValueCollection();
                        values("thing1") = "hello";
                        values("thing2") = "world";

                        var response = client.UploadValues("https://postman-echo.com/post", values);

                        responsebody = "done" + Encoding.Default.GetString(response);
                    }
                }
                catch (Exception abc) {
                    throw abc;
                }
                currentItem("MajorCategoryConfidence") = responsebody;
                currentItem.Update();

            }
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine("error{0}", ex.Message);
            System.IO.File.WriteAllText("C:\Temp\ErrorLogBT.txt", ex.Message);
            throw ex;
        }
    }


}

}

Algorithms: routes of k-disjoint pairs where any source can be paired with any sink

I have a question about a problem I am working on.

The problem is with an MxN grid with k sources and sinks, find routes that do not cross so that all sources are paired with a sump. Sumps can only be used by a single source, and any source can be paired with any sink.

The underlying problem is NP-Hard, but according to a vague comment I found, with the given restriction, it can be solved in polynomial time. Unfortunately, I can't find any relevant literature that can help.

https://stackoverflow.com/questions/19404033/all-pairs-maximally-disjoint-paths-algorithm/19411277#19411277

If someone could show me evidence or documents that discuss this problem, I would appreciate it.

Why do the Cons complain that Muslims force their religion to sink when they do the same with Christianity?

Amen. In fact, the main excuse that ISIS and others give for their atrocities against the infidels is that they are only defending Islam according to the Koran. Of course, ISIS et al. omit the part of the Quran that says you should first try to convert the infidels to Islam … before decapitating them.

Anyway, the Mormons with their required testimony, the evangelicals with their dissemination, and so on. Isn't it surprising that other religions are suspicious and defensive against Christians?

.

Serialization functions: accept a sink instead of returning the result

What are the advantages and disadvantages of having a serialization function that accepts a sink?

Foo class:
def toString (self, stringIOSink):
happen

def toBytes (self, byteSink):
happen

instead of having the serialization function return the result:

Foo class:
def toString (self):
# ..
returns

def toBytes (self):
# ..
return bytes

(Obviously, this approach is the standard when serializing a string)

I have seen so much in nature as before, I have never thought much about it. Note that my examples are in python, but I am asking in a language agnostic context.

Considerations that I have thought:

accepting a sink

  • the implementation does not need to allocate memory (and, therefore, the client does not have to worry about how the memory is managed)
  • can transmit the output

return result

  • possibly more simple
  • allows you to manipulate / use the returned result. For example, if we are serializing to JSON (similar to Python's JSON decoding operation), then yes Foo has a list of Pub objects, then we can implement Foois aJSON method by
def toJSON (auto):
he came back {
# other members here
"bars": [b.toJSON() for b in self.bars],
}

Which would not be possible if aJSON He accepted some kind of JSON sink.

sink the blue tooth into a mobile phone and receive text messages from the phone /

If you connect your blue tooth to a truck for music, can the owner of that truck download your text messages without your knowledge or can you download the messages that have been left out?

sharepoint addin – Debug remote event sink: – "Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException..localhost is not the desired audience"

I want to debug our remote event receiver for a collection of sharepoint online sites. and because the Azure service bus function for RER debugging is no longer supported. so I'm trying to use the Ngrok the attachment I did these steps: –

one- Inside Visual Studio 2015 >> create a new sharepoint plug-in >> write a plug-in hosted by the provider >> Enter the url for a collection of test business wiki sites that have the application side loading feature enabled.
enter the description of the image here

two- Then I enabled the installed / uninstalled plug-in identifier: –
enter the description of the image here

3- Then inside the AppEventReceiver.svc I entered the code of this code + the implementation of the methods:

    SPRemoteEventResult Public ProcessEvent (SPRemoteEventProperties properties)
{
SPRemoteEventResult result = new SPRemoteEventResult ();

switch (properties.EventType)
{
case SPRemoteEventType.AppInstalled:
HandleAppInstalled (properties);
break;
SPRemoteEventType.AppUninstalling case:
HandleAppUninstalling (properties);
break;
SPRemoteEventType.ItemAdded case:
HandleItemAdded (properties);
break;
}


return result
}
// The code goes here for the implementation of the previous methods.

To debug the RER, I did these steps:

one- I execute this ngrok command: –

ngrok http --host-header = rewrite 54001 // where this port is our RER port inside Visual Studio

two- Update the update web.config, with the url that I got from the previous command:
enter the description of the image here

3- Set the web application as a startup project.

4- Navigate to Ngrok url where I got this page: –
enter the description of the image here

5- Register the application and update the web.config with the ClientId + ClientSecret generated
enter the description of the image here
enter the description of the image here

6- After that I ran the Visual Studio project >> I received this message to trust the application: –
enter the description of the image here

7- Where the application starts to be displayed within the content page of the site with a message that is added …

8- After my code reached this point of interruption: –
enter the description of the image here

9- But within the TokenHelper.cs , I have this exception **: –

An exception of type & # 39; Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException & # 39;
occurred in **** Web.dll but was not handled in the user code
Additional information: "localhost" is not the desired audience "f15f8358-54c4-4767-95b2-98051ed0b1c5/00af9b86.ngrok.io@8208ba41-935e-4b54-ace7-

in this code: –
enter the description of the image here

So, can anyone advise on this please?

c ++ – Boost log sink – Timestamp attribute and formatter problem

I have implemented a sink that registers the records in a std :: vector and empties all the records in the console when the download function is called. I have added four attributes according to:

BOOST_LOG_ATTRIBUTE_KEYWORD (a timestamp, "TimeStamp", boost :: log :: attributes :: local_clock :: value_type)
BOOST_LOG_ATTRIBUTE_KEYWORD (a_severity, "Severity", boost :: log :: trivial :: severity_level)
BOOST_LOG_ATTRIBUTE_KEYWORD (a_file, "File", std :: string)
BOOST_LOG_ATTRIBUTE_KEYWORD (a_line, "Line", std :: string)

However, when I use the set_formatter function, I get a compiler error (MSVC17) that says:

Binary error C2679 & # 39; << & # 39 ;: no operator was found to take the right hand
Operand of type & # 39; const T & # 39; (or there is not acceptable
conversion) Software Driver c: local boost_1_68_0 boost log utility formatting_ostream.hpp 870

I will provide the complete code for the sake of clarity:

// cswlogger.h
#pragma once

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 


namespace sinks = boost :: log :: seks;

BOOST_LOG_GLOBAL_LOGGER (sysLogger,
boost :: log :: sources :: severity_logger_mt);


CswLogger class
{
public:
/// Init with default information level record
static void init (bool useRamLog = false, boost :: log :: trivial :: severity_level level = boost :: log :: trivial :: info);

/// Deactivate the registration
static vacuum deactivation ();

// Download log
static void flushLogs ();

// Convert the file path to just the file name
static std :: string path_to_filename (std :: string path)
{
returns path.substr (path.find_last_of ("/ \") + 1);
}
private:
static void registerRamLog ();
};

RamLogSink class:
public sinks :: basic_formatted_sink_backend <
char,
sinks :: combine_requirements<
    sinks::synchronized_feeding,
    sinks::flushing
    >::kind
>
{
public:
// The function consumes the records that come from the interface
void consume (boost :: log :: record_view const & rec, string_type const & strType);
// The function empties the records in the vector
empty empty ();
private:
std :: vector logEntries_;

};
// Type of complete sink
typedef sinks :: synchronous_sink< RamLogSink > sink_t;

#define LOG_LOG_LOCATION (LOGGER, LEVEL, ARG) 
BOOST_LOG_SEV (LOGGER, boost :: log :: trivial :: LEVEL) 
<< boost :: log :: add_value ("Line", std :: to_string (__ LINE__)) 
<< boost :: log :: add_value ("File", CswLogger :: path_to_filename (__ FILE__)) << ARG


// System of registry macros.
// TRACE <DEBUG <INFO <WARN <ERROR <FATAL
#define LOG_TRACE (ARG) LOG_LOG_LOCATION (sysLogger :: get (), trace, ARG);
#define LOG_DEBUG (ARG) LOG_LOG_LOCATION (sysLogger :: get (), debug, ARG);
#define LOG_INFO (ARG) LOG_LOG_LOCATION (sysLogger :: get (), info, ARG);
#define LOG_WARN (ARG) LOG_LOG_LOCATION (sysLogger :: get (), warning, ARG);
#define LOG_ERROR (ARG) LOG_LOG_LOCATION (sysLogger :: get (), error, ARG);
#define LOG_FATAL (ARG) LOG_LOG_LOCATION (sysLogger :: get (), fatal, ARG);

Source file:

// cswlogger.cpp

#include "cswlogger.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 



BOOST_LOG_GLOBAL_LOGGER_DEFAULT (sysLogger,
boost :: log :: sources :: severity_channel_logger_mt);


BOOST_LOG_ATTRIBUTE_KEYWORD (a timestamp, "TimeStamp", boost :: log :: attributes :: local_clock :: value_type)
BOOST_LOG_ATTRIBUTE_KEYWORD (a_severity, "Severity", boost :: log :: trivial :: severity_level)
BOOST_LOG_ATTRIBUTE_KEYWORD (a_file, "File", std :: string)
BOOST_LOG_ATTRIBUTE_KEYWORD (a_line, "Line", std :: string)

void CswLogger :: init (bool useRamLog, boost :: log :: trivial :: severity_level level)
{
boost :: log :: register_simple_formatter_factory("Gravity");

if (useRamLog)
{
registerRamLog ();
}
plus
{
boost :: log :: add_console_log
(
std :: obstruction,
boost :: log :: keywords :: format = "[%TimeStamp%] [%Severity%]    % File% (% line%):% message% "
);
}

boost :: log :: add_common_attributes ();
boost :: log :: core :: get () -> set_filter
(
boost :: log :: trivial :: severity> = level
);

// Indicate start of registration
LOG_INFO ("Log Start");
}

void CswLogger :: disable ()
{
boost :: log :: core :: get () -> set_logging_enabled (false);
}

void CswLogger :: flushLogs ()
{
boost :: log :: core :: get () -> flush ();
}

void CswLogger :: registerRamLog ()
{
Impulse :: shared_ptr< RamLogSink > backend (new RamLogSink ());
Impulse :: shared_ptr< sink_t > sink (new sink_t (backend));
sink-> set_formatter (boost :: log :: expressions :: stream
<<[" << a_timestamp << "] "// <--- compilation error here
<<[" << a_severity << "] "
<<[" << a_file << "(" << a_line << ")] "
<< boost::log::expressions::message);

    boost::log::core::get()->add_sink (sink);
}

// Declarations of the RamlogSink class
void RamLogSink :: consume (boost :: log :: record_view const & rec, string_type const & strType)
{
logEntries_.emplace_back (strType);
}

void RamLogSink :: flush ()
{
for (auto const and entry: logEntries_)
{
std :: cout << entry << std :: endl;
}
logEntries_.clear ();
}

main.cpp:

#include "cswlogger.h"

CswLogger :: init (true);
LOG_TRACE ("This should not be printed");
LOG_ERROR ("Very bad error that needs to be printed");
int theInt = 234;
LOG_FATAL ("TheInt integer is:" << theInt);
CswLogger :: flushLogs ();

I also had a problem adding the "Line" attribute with:

BOOST_LOG_ATTRIBUTE_KEYWORD (a_line, "Line", int)

Hade to change to std :: string and convert the integer to a string in

#define LOG_LOG_LOCATION (LOGGER, LEVEL, ARG) 
BOOST_LOG_SEV (LOGGER, boost :: log :: trivial :: LEVEL) 
<< boost :: log :: add_value ("Line", std :: to_string (__ LINE__)) 
<< boost :: log :: add_value ("File", CswLogger :: path_to_filename (__ FILE__)) << ARG

Otherwise, the line number came out as an empty string.

sharepoint online – Installing a remote event sink add-in – System.IdentityModel.Tokens.SecurityTokenException

I am working with a remote event receiver add-in in SharePoint Online and when I try to install the add-on at the point of interruption in the HandleAppInstalled (); is activated, but when you try to use ClientContext to call the installation method, an exception occurs and the add-in can not be installed.

enter the description of the image here

The exception as follows:

enter the description of the image here

The plugin is hosted as a web application in Azure, and I'm using Cloud Explorer to debug it. It is assumed that the RER is installed in the "Site Pages" library and is activated when a file is Registered in.

I tried:

  • Register the add-on with the new customer ID and secret, in the catalog and update the values ​​in the project.
  • The framework from v4.6 to v4.7 was updated.
  • Supplement events complement Complement uninstalled and installed in True (in properties)
  • The project is established in the hosted provider and the plug-in is connected to the correct web project.
  • Probably more things that I can not think now haha

enter the description of the image here

I appreciate any help or suggestion I can get!