

# PutLoggingConfiguration
<a name="API_PutLoggingConfiguration"></a>

Enables the specified [LoggingConfiguration](API_LoggingConfiguration.md), to start logging from a web ACL, according to the configuration provided. 

If you configure data protection for the web ACL, the protection applies to the data that Amazon WAF sends to the logs. 

**Note**  
This operation completely replaces any mutable specifications that you already have for a logging configuration with the ones that you provide to this call.   
To modify an existing logging configuration, do the following:   
Retrieve it by calling [GetLoggingConfiguration](API_GetLoggingConfiguration.md) 
Update its settings as needed
Provide the complete logging configuration specification to this call

**Note**  
You can define one logging destination per web ACL.

You can access information about the traffic that Amazon WAF inspects using the following steps:

1. Create your logging destination. You can use an Amazon CloudWatch Logs log group, an Amazon Simple Storage Service (Amazon S3) bucket, or an Amazon Kinesis Data Firehose. 

   The name that you give the destination must start with `aws-waf-logs-`. Depending on the type of destination, you might need to configure additional settings or permissions. 

   For configuration requirements and pricing information for each destination type, see [Logging web ACL traffic](https://docs.amazonaws.cn/waf/latest/developerguide/logging.html) in the * Amazon WAF Developer Guide*.

1. Associate your logging destination to your web ACL using a `PutLoggingConfiguration` request.

When you successfully enable logging using a `PutLoggingConfiguration` request, Amazon WAF creates an additional role or policy that is required to write logs to the logging destination. For an Amazon CloudWatch Logs log group, Amazon WAF creates a resource policy on the log group. For an Amazon S3 bucket, Amazon WAF creates a bucket policy. For an Amazon Kinesis Data Firehose, Amazon WAF creates a service-linked role.

For additional information about web ACL logging, see [Logging web ACL traffic information](https://docs.amazonaws.cn/waf/latest/developerguide/logging.html) in the * Amazon WAF Developer Guide*.

## Request Syntax
<a name="API_PutLoggingConfiguration_RequestSyntax"></a>

```
{
   "LoggingConfiguration": { 
      "LogDestinationConfigs": [ "string" ],
      "LoggingFilter": { 
         "DefaultBehavior": "string",
         "Filters": [ 
            { 
               "Behavior": "string",
               "Conditions": [ 
                  { 
                     "ActionCondition": { 
                        "Action": "string"
                     },
                     "LabelNameCondition": { 
                        "LabelName": "string"
                     }
                  }
               ],
               "Requirement": "string"
            }
         ]
      },
      "LogScope": "string",
      "LogType": "string",
      "ManagedByFirewallManager": boolean,
      "RedactedFields": [ 
         { 
            "AllQueryArguments": { 
            },
            "Body": { 
               "OversizeHandling": "string"
            },
            "Cookies": { 
               "MatchPattern": { 
                  "All": { 
                  },
                  "ExcludedCookies": [ "string" ],
                  "IncludedCookies": [ "string" ]
               },
               "MatchScope": "string",
               "OversizeHandling": "string"
            },
            "HeaderOrder": { 
               "OversizeHandling": "string"
            },
            "Headers": { 
               "MatchPattern": { 
                  "All": { 
                  },
                  "ExcludedHeaders": [ "string" ],
                  "IncludedHeaders": [ "string" ]
               },
               "MatchScope": "string",
               "OversizeHandling": "string"
            },
            "JA3Fingerprint": { 
               "FallbackBehavior": "string"
            },
            "JA4Fingerprint": { 
               "FallbackBehavior": "string"
            },
            "JsonBody": { 
               "InvalidFallbackBehavior": "string",
               "MatchPattern": { 
                  "All": { 
                  },
                  "IncludedPaths": [ "string" ]
               },
               "MatchScope": "string",
               "OversizeHandling": "string"
            },
            "Method": { 
            },
            "QueryString": { 
            },
            "SingleHeader": { 
               "Name": "string"
            },
            "SingleQueryArgument": { 
               "Name": "string"
            },
            "UriFragment": { 
               "FallbackBehavior": "string"
            },
            "UriPath": { 
            }
         }
      ],
      "ResourceArn": "string"
   }
}
```

## Request Parameters
<a name="API_PutLoggingConfiguration_RequestParameters"></a>

For information about the parameters that are common to all actions, see [Common Parameters](CommonParameters.md).

The request accepts the following data in JSON format.

 ** [LoggingConfiguration](#API_PutLoggingConfiguration_RequestSyntax) **   <a name="WAF-PutLoggingConfiguration-request-LoggingConfiguration"></a>
  
Type: [LoggingConfiguration](API_LoggingConfiguration.md) object  
Required: Yes

## Response Syntax
<a name="API_PutLoggingConfiguration_ResponseSyntax"></a>

```
{
   "LoggingConfiguration": { 
      "LogDestinationConfigs": [ "string" ],
      "LoggingFilter": { 
         "DefaultBehavior": "string",
         "Filters": [ 
            { 
               "Behavior": "string",
               "Conditions": [ 
                  { 
                     "ActionCondition": { 
                        "Action": "string"
                     },
                     "LabelNameCondition": { 
                        "LabelName": "string"
                     }
                  }
               ],
               "Requirement": "string"
            }
         ]
      },
      "LogScope": "string",
      "LogType": "string",
      "ManagedByFirewallManager": boolean,
      "RedactedFields": [ 
         { 
            "AllQueryArguments": { 
            },
            "Body": { 
               "OversizeHandling": "string"
            },
            "Cookies": { 
               "MatchPattern": { 
                  "All": { 
                  },
                  "ExcludedCookies": [ "string" ],
                  "IncludedCookies": [ "string" ]
               },
               "MatchScope": "string",
               "OversizeHandling": "string"
            },
            "HeaderOrder": { 
               "OversizeHandling": "string"
            },
            "Headers": { 
               "MatchPattern": { 
                  "All": { 
                  },
                  "ExcludedHeaders": [ "string" ],
                  "IncludedHeaders": [ "string" ]
               },
               "MatchScope": "string",
               "OversizeHandling": "string"
            },
            "JA3Fingerprint": { 
               "FallbackBehavior": "string"
            },
            "JA4Fingerprint": { 
               "FallbackBehavior": "string"
            },
            "JsonBody": { 
               "InvalidFallbackBehavior": "string",
               "MatchPattern": { 
                  "All": { 
                  },
                  "IncludedPaths": [ "string" ]
               },
               "MatchScope": "string",
               "OversizeHandling": "string"
            },
            "Method": { 
            },
            "QueryString": { 
            },
            "SingleHeader": { 
               "Name": "string"
            },
            "SingleQueryArgument": { 
               "Name": "string"
            },
            "UriFragment": { 
               "FallbackBehavior": "string"
            },
            "UriPath": { 
            }
         }
      ],
      "ResourceArn": "string"
   }
}
```

## Response Elements
<a name="API_PutLoggingConfiguration_ResponseElements"></a>

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

 ** [LoggingConfiguration](#API_PutLoggingConfiguration_ResponseSyntax) **   <a name="WAF-PutLoggingConfiguration-response-LoggingConfiguration"></a>
  
Type: [LoggingConfiguration](API_LoggingConfiguration.md) object

## Errors
<a name="API_PutLoggingConfiguration_Errors"></a>

For information about the errors that are common to all actions, see [Common Error Types](CommonErrors.md).

 ** WAFFeatureNotIncludedInPricingPlanException **   
The operation failed because the specified Amazon WAF feature isn't supported by the CloudFront pricing plan associated with the web ACL.    
 ** DisallowedFeatures **   
The names of the disallowed Amazon WAF features.
HTTP Status Code: 400

 ** WAFInternalErrorException **   
Your request is valid, but Amazon WAF couldn’t perform the operation because of a system problem. Retry your request.   
HTTP Status Code: 500

 ** WAFInvalidOperationException **   
The operation isn't valid.   
HTTP Status Code: 400

 ** WAFInvalidParameterException **   
The operation failed because Amazon WAF didn't recognize a parameter in the request. For example:   
+ You specified a parameter name or value that isn't valid.
+ Your nested statement isn't valid. You might have tried to nest a statement that can’t be nested. 
+ You tried to update a `WebACL` with a `DefaultAction` that isn't among the types available at [DefaultAction](API_DefaultAction.md).
+ Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL can't be associated.  
 ** Field **   
The settings where the invalid parameter was found.   
 ** Parameter **   
The invalid parameter that resulted in the exception.   
 ** Reason **   
Additional information about the exception.
HTTP Status Code: 400

 ** WAFLimitsExceededException **   
 Amazon WAF couldn’t perform the operation because you exceeded your resource limit. For example, the maximum number of `WebACL` objects that you can create for an Amazon account. For more information, see [Amazon WAF quotas](https://docs.amazonaws.cn/waf/latest/developerguide/limits.html) in the * Amazon WAF Developer Guide*.    
 ** SourceType **   
Source type for the exception. 
HTTP Status Code: 400

 ** WAFLogDestinationPermissionIssueException **   
The operation failed because you don't have the permissions that your logging configuration requires. For information, see [Logging web ACL traffic information](https://docs.amazonaws.cn/waf/latest/developerguide/logging.html) in the * Amazon WAF Developer Guide*.  
HTTP Status Code: 400

 ** WAFNonexistentItemException **   
 Amazon WAF couldn’t perform the operation because your resource doesn't exist. If you've just created a resource that you're using in this operation, you might just need to wait a few minutes. It can take from a few seconds to a number of minutes for changes to propagate.   
HTTP Status Code: 400

 ** WAFOptimisticLockException **   
 Amazon WAF couldn’t save your changes because you tried to update or delete a resource that has changed since you last retrieved it. Get the resource again, make any changes you need to make to the new copy, and retry your operation.   
HTTP Status Code: 400

 ** WAFServiceLinkedRoleErrorException **   
 Amazon WAF is not able to access the service linked role. This can be caused by a previous `PutLoggingConfiguration` request, which can lock the service linked role for about 20 seconds. Please try your request again. The service linked role can also be locked by a previous `DeleteServiceLinkedRole` request, which can lock the role for 15 minutes or more. If you recently made a call to `DeleteServiceLinkedRole`, wait at least 15 minutes and try the request again. If you receive this same exception again, you will have to wait additional time until the role is unlocked.  
HTTP Status Code: 400

## See Also
<a name="API_PutLoggingConfiguration_SeeAlso"></a>

For more information about using this API in one of the language-specific Amazon SDKs, see the following:
+  [Amazon Command Line Interface V2](https://docs.amazonaws.cn/goto/cli2/wafv2-2019-07-29/PutLoggingConfiguration) 
+  [Amazon SDK for .NET V4](https://docs.amazonaws.cn/goto/DotNetSDKV4/wafv2-2019-07-29/PutLoggingConfiguration) 
+  [Amazon SDK for C\$1\$1](https://docs.amazonaws.cn/goto/SdkForCpp/wafv2-2019-07-29/PutLoggingConfiguration) 
+  [Amazon SDK for Go v2](https://docs.amazonaws.cn/goto/SdkForGoV2/wafv2-2019-07-29/PutLoggingConfiguration) 
+  [Amazon SDK for Java V2](https://docs.amazonaws.cn/goto/SdkForJavaV2/wafv2-2019-07-29/PutLoggingConfiguration) 
+  [Amazon SDK for JavaScript V3](https://docs.amazonaws.cn/goto/SdkForJavaScriptV3/wafv2-2019-07-29/PutLoggingConfiguration) 
+  [Amazon SDK for Kotlin](https://docs.amazonaws.cn/goto/SdkForKotlin/wafv2-2019-07-29/PutLoggingConfiguration) 
+  [Amazon SDK for PHP V3](https://docs.amazonaws.cn/goto/SdkForPHPV3/wafv2-2019-07-29/PutLoggingConfiguration) 
+  [Amazon SDK for Python](https://docs.amazonaws.cn/goto/boto3/wafv2-2019-07-29/PutLoggingConfiguration) 
+  [Amazon SDK for Ruby V3](https://docs.amazonaws.cn/goto/SdkForRubyV3/wafv2-2019-07-29/PutLoggingConfiguration) 