LogTerminal 2.2.1

Requires NuGet 3.3.0 or higher.

dotnet add package LogTerminal --version 2.2.1
                    
NuGet\Install-Package LogTerminal -Version 2.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LogTerminal" Version="2.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LogTerminal" Version="2.2.1" />
                    
Directory.Packages.props
<PackageReference Include="LogTerminal" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LogTerminal --version 2.2.1
                    
#r "nuget: LogTerminal, 2.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LogTerminal@2.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LogTerminal&version=2.2.1
                    
Install as a Cake Addin
#tool nuget:?package=LogTerminal&version=2.2.1
                    
Install as a Cake Tool

Infos

This package support X64.

This package can work with serilog.skin.LogTerminal

Update details

[/ - /] Version 1.1.0 to 2.1.2 can only work for .NET FrameWork project, if need use it in .NET project, must copy PublicTerminalCore.dll (in folder:$(OutDir)runtimes/win-x64/native) to project output root folder! [250827 - V2.2.1] Fix nuget package install issue. This package can work with .NET FrameWork and .NET.

How to use

1/ In MainWidow.xaml

Add namespace

<Window
    ...
    xmlns:term="clr-namespace:Microsoft.Terminal.Wpf;assembly=Microsoft.Terminal.Wpf"
    ...
>
<Grid>
<term:TerminalControl
    x:Name="Terminal"
    BuffSzie="512"
    Focusable="true" />
</Grid>
</Window>

2/ In MainWindow.xaml.cs

using Microsoft.Terminal.Wpf;
using System;
using System.Windows;

namespace WpfApp1
{
    public class EchoConnection : Microsoft.Terminal.Wpf.ITerminalConnection
    {
        public event EventHandler<TerminalOutputEventArgs> TerminalOutput;

        public event EventHandler<TerminalLogOutputEventArgs> TerminalLogOutput;

        public void Resize(uint rows, uint columns)
        {
            return;
        }

        public void Start()
        {
            TerminalOutput.Invoke(this, new TerminalOutputEventArgs("ECHO CONNECTION\r\n^A: toggle printable ESC\r\n^B: toggle SGR mouse mode\r\n^C: toggle win32 input mode\r\n\r\n"));
            return;
        }

        private bool _escapeMode;
        private bool _mouseMode;
        private bool _win32InputMode;
        int count = 0;

        public void WriteInput(string data)
        {
            if (data.Length == 0)
            {
                return;
            }

            if (data[0] == '\x01') // ^A
            {
                _escapeMode = !_escapeMode;
                TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"Printable ESC mode: {_escapeMode}\r\n"));
            }
            else if (data[0] == '\x02') // ^B
            {
                _mouseMode = !_mouseMode;
                var decSet = _mouseMode ? "h" : "l";
                TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"\x1b[?1003{decSet}\x1b[?1006{decSet}"));
                TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"SGR Mouse mode (1003, 1006): {_mouseMode}\r\n"));
            }
            else if ((data[0] == '\x03') ||(data == "\x1b[67;46;3;1;8;1_")) // ^C
            {
                _win32InputMode = !_win32InputMode;
                var decSet = _win32InputMode ? "h" : "l";
                TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"\x1b[?9001{decSet}"));
                TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"Win32 input mode: {_win32InputMode}\r\n"));

                // If escape mode isn't currently enabled, turn it on now.
                if (_win32InputMode && !_escapeMode)
                {
                    _escapeMode = true;
                    TerminalOutput.Invoke(this, new TerminalOutputEventArgs($"Printable ESC mode: {_escapeMode}\r\n"));
                }
            }
            else
            {
                // Echo back to the terminal, but make backspace/newline work properly.
                var str = data.Replace("\r", "\r\n").Replace("\x7f", "\x08 \x08");
                if (_escapeMode)
                {
                    str = str.Replace("\x1b", "\u241b");
                }
                //direct output
                //TerminalOutput.Invoke(this, new TerminalOutputEventArgs(str));
                TerminalLogOutput.Invoke(this, new TerminalLogOutputEventArgs(TerminalLogOutputEventArgs.LogLevel.Verbose, "Verbose test log. User input:" + str));
                TerminalLogOutput.Invoke(this, new TerminalLogOutputEventArgs(TerminalLogOutputEventArgs.LogLevel.Info, "Info test log. User input:" + str));
                TerminalLogOutput.Invoke(this, new TerminalLogOutputEventArgs(TerminalLogOutputEventArgs.LogLevel.Warning, "Warning test log. User input:" + str));
                TerminalLogOutput.Invoke(this, new TerminalLogOutputEventArgs(TerminalLogOutputEventArgs.LogLevel.Error, "Error test log. User input:" + str));
                TerminalLogOutput.Invoke(this, new TerminalLogOutputEventArgs(TerminalLogOutputEventArgs.LogLevel.Fatel, "Fatel test log. User input:" + str));
            }
        }

        public void Close()
        {
            return;
        }

    }

    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Terminal.Loaded += Terminal_Loaded;
        }

        private void Terminal_Loaded(object sender, RoutedEventArgs e)
        {
            var theme = new TerminalTheme
            {
                DefaultBackground = 0x0c0c0c,
                DefaultForeground = 0xcccccc,
                DefaultSelectionBackground = 0xcccccc,
                SelectionBackgroundAlpha = 0.5f,
                CursorStyle = CursorStyle.BlinkingBar,
                // This is Campbell.
                ColorTable = new uint[] { 0x0C0C0C, 0x1F0FC5, 0x0EA113, 0x009CC1, 0xDA3700, 0x981788, 0xDD963A, 0xCCCCCC, 0x767676, 0x5648E7, 0x0CC616, 0xA5F1F9, 0xFF783B, 0x9E00B4, 0xD6D661, 0xF2F2F2 },
            };
            Terminal.Connection = new EchoConnection();
            Terminal.SetTheme(theme, "Cascadia Code", 12);
            Terminal.Focus();
        }

    }
    
}
Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.7.2

    • No dependencies.
  • net6.0-windows7.0

    • No dependencies.
  • net8.0-windows7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on LogTerminal:

Package Downloads
Serilog.Sinks.LogTerminal

Serilog sink for LogTerminal

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.1 222 8/27/2025
2.1.2 263 8/25/2025
1.1.2 153 11/18/2024
1.1.1 139 11/14/2024
1.1.0 253 11/11/2023
1.0.0 210 8/29/2023 1.0.0 is deprecated because it has critical bugs.
0.1.5 363 8/28/2023 0.1.5 is deprecated.
0.1.4 360 8/28/2023 0.1.4 is deprecated.
0.1.3 350 8/28/2023 0.1.3 is deprecated.
0.1.2 359 8/28/2023 0.1.2 is deprecated.
0.1.1 349 8/28/2023 0.1.1 is deprecated.
0.1.0 371 8/28/2023 0.1.0 is deprecated.

This package support X64.
This package can work with serilog.skin.LogTerminal

[250827 - V2.2.1] Fix nuget package install issue. This package can work with .NET FrameWork and .NET.