Get-AzContainerInstanceLog

Get the logs of a container instance in a container group.

Syntax

Get-AzContainerInstanceLog
   [-ResourceGroupName] <String>
   -ContainerGroupName <String>
   [-Name <String>]
   [-Tail <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzContainerInstanceLog
   -InputContainerGroup <PSContainerGroup>
   [-Name <String>]
   [-Tail <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzContainerInstanceLog
   -ResourceId <String>
   [-Name <String>]
   [-Tail <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The Get-AzContainerInstanceLog cmdlet gets the logs of a container in a container group.

Examples

Example 1: Get the tail log of a container instance

PS C:\> Get-AzContainerInstanceLog -ResourceGroupName demo -ContainerGroupName mycontainer -Name container1

Log line 1.
Log line 2.
Log line 3.
Log line 4.

Get the log from container1 in container group mycontainer. By default, it will return up to 4MB log content.

Example 2: Get the tail log of a container instance that has the same name as the container group

PS C:\> Get-AzContainerInstanceLog -ResourceGroupName demo -ContainerGroupName mycontainer

Log line 1.
Log line 2.
Log line 3.
Log line 4.

Get the log from mycontainer in container group mycontainer. By default, it will return up to 4MB log content.

Example 3: Get the tail 2 lines of log of a container instance

PS C:\> Get-AzContainerInstanceLog -ResourceGroupName demo -ContainerGroupName mycontainer -Name container1 -Tail 2

Log line 3.
Log line 4.

Get the tail 2 lines of log from container1 in container group mycontainer.

Example 4: Get the tail log of a container instance in a piped in container group

PS C:\> Get-AzContainerGroup -ResourceGroupName demo -Name mycontainer | Get-AzContainerInstanceLog

Log line 1.
Log line 2.
Log line 3.
Log line 4.

Get the log from mycontainer in piped in container group mycontainer. By default, it will return up to 4MB log content.

Parameters

-ContainerGroupName

The container group name.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InputContainerGroup

The input container group object.

Type:PSContainerGroup
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-Name

The container instance name in the container group. Default: the same as the container group name

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ResourceGroupName

The resource group name.

Type:String
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ResourceId

The resource id.

Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Tail

The number of lines to tail the log. If not specify, the cmdlet will return up to 4MB tailed log

Type:System.Nullable`1[System.Int32]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

PSContainerGroup

String

Outputs

String